需求:添加类对象属性,在新建具体对象时使用该变量
class A():
def __init__(self,name):
self.name = name
self.config = {'batch_size':A.bs}
@classmethod
def set_bs(cls,bs):
cls.bs = bs
def print_config(self):
print (self.config)
A.set_bs(4)
a = A('test')
a.print_config()