换一种写法不可以吗
class Person(object):
def __init__(self, name, gender, birth, **kw):
self.name = name
self.gender = gender
self.birth = birth
for k, v in kw.iteritems():
self.k = v
不用setattr 这样写为什么不可以
class Person(object):
def __init__(self, name, gender, birth, **kw):
self.name = name
self.gender = gender
self.birth = birth
for k, v in kw.iteritems():
self.k = v
不用setattr 这样写为什么不可以
2018-11-27
举报