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():
setattr(self,k,v)
xiaoming = Person('Xiao Ming', 'Male', '1990-1-1', job='Student')
print xiaoming.name
print xiaoming.job
请问一下
self.name=name
self.gender=gender
self.birth=birth
这几句代码有什么作用?意义?
另外*args和**kw有什么区别?还有**args,**kwargs?
ruibin
相关分类