python中@classmethod @staticmethod的使用方法及区别

https://stackoverflow.com/questions/136097/difference-between-staticmethod-and-classmethod
@staticmethod:如果类里面不想某个方法使用类属性和调用其它方法就可以使用静态方法,有助于优化代码结构和提高程序的可读性。
@classmethod:用cls代替self,无需实例化类即可使用。
可以参考:https://www.cnblogs.com/lucktomato/p/15175084.html

posted @ 2022-11-09 17:44  LevisL  阅读(39)  评论(0)    收藏  举报