fed浅谈Python内 def 与 class 的区别--知识点整理(B站 - BV11g411w73x)_pythonclass和def的区别_奋进的小咸鱼的博客-CSDN博客def 是用于函数的封装代码如下:def jianfa(a,b): print(a-b) jianfa(100,9)输出结果:91class可用于多个函数的封装,是一种面向对象的类使用class需要初始化的class maidanglao(): def __init__(self): #初始化 print("今晚吃三碗饭")n = maidanglao() #这一步就是在实例化对象输出结果:今晚吃三碗饭_pythonclass和def的区别https://blog.csdn.net/weixin_45546132/article/details/122105742?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522169475925416800222878111%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=169475925416800222878111&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-9-122105742-null-null.142^v94^insert_down28v1&utm_term=class%E5%92%8Cdef&spm=1018.2226.3001.4187def 是用于函数的封装代码如下:def jianfa(a,b): print(a-b) jianfa(100,9)输出结果:91class可用于多个函数的封装,是一种面向对象的类使用class需要初始化的class maidanglao(): def __init__(self): #初始化 print("今晚吃三碗饭")n = maidanglao() #这一步就是在实例化对象输出结果:今晚吃三碗饭_pythonclass和def的区别https://blog.csdn.net/weixin_45546132/article/details/122105742?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522169475925416800222878111%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=169475925416800222878111&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-9-122105742-null-null.142^v94^insert_down28v1&utm_term=class%E5%92%8Cdef&spm=1018.2226.3001.4187def 是用于函数的封装代码如下:def jianfa(a,b): print(a-b) jianfa(100,9)输出结果:91class可用于多个函数的封装,是一种面向对象的类使用class需要初始化的class maidanglao(): def __init__(self): #初始化 print("今晚吃三碗饭")n = maidanglao() #这一步就是在实例化对象输出结果:今晚吃三碗饭_pythonclass和def的区别https://blog.csdn.net/weixin_45546132/article/details/122105742?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522169475925416800222878111%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=169475925416800222878111&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-9-122105742-null-null.142^v94^insert_down28v1&utm_term=class%E5%92%8Cdef&spm=1018.2226.3001.4187def 是用于函数的封装代码如下:def jianfa(a,b): print(a-b) jianfa(100,9)输出结果:91class可用于多个函数的封装,是一种面向对象的类使用class需要初始化的class maidanglao(): def __init__(self): #初始化 print("今晚吃三碗饭")n = maidanglao() #这一步就是在实例化对象输出结果:今晚吃三碗饭_pythonclass和def的区别https://blog.csdn.net/weixin_45546132/article/details/122105742?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522169475925416800222878111%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=169475925416800222878111&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-9-122105742-null-null.142^v94^insert_down28v1&utm_term=class%E5%92%8Cdef&spm=1018.2226.3001.4187