1. 作用
一般直接使用类来调用方法
2. 操作
# 静态方法
# staticmethod
class Hero(object):
def __init__(self, name):
self.name = name
def set_name(self, name):
self.name = name
@staticmethod
def move(action):
print('{}......'.format(action))
@classmethod
def say(cls, words):
print('{} say {}...'.format(cls, words))
superman = Hero('Mario')
superman.set_name('Tommy')
superman.move('flying')
Hero.move('running')
Hero.say('go go go...')