前面在类里面定义了 def cm(cls): 和def method(): ,但是后来这样输入:Student.cm()和Student.method() 会报错:AttributeError: type object 'Student' has no attribute 'method',求大神解一下
def method() 这个方法没有cls参数 怎么能直接用类调用呢? 这就是个普通方法 method() 这样调用才对,类里面的方法看你传参的
Python进阶-----静态方法(@staticmethod) - Meanwey - 博客园 python中类的静态方法,通过内置装饰器@staticmethod来实现 https://www.cnblogs.com/Meanwey/p/9788713.html