为什么直接在for循环里写 self.k = v 不行?
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或者 dict的update,这两个有什么区别呢?
xiaoming = Person('Xiao Ming', 'Male', '1990-1-1', job='Student')
print xiaoming.name
print xiaoming.job