类方法和静态方法都实例化的对象无关,但到底有什么区别呢
class Employee:
@classmethod
def classmthd(*args):
return args
@staticmethod
def staticmthd(*args):
return args
# 类方法
print(Employee.classmthd())
print(Employee.classmthd('test'))
# 静态方法
print(Employee.staticmthd())
print(Employee.staticmthd('test'))
(class '__main__.Employee',)
(class '__main__.Employee', 'test')
()
('test',)