求大神解釋???
class Person(object):
? ? def __init__(self,name,gender,birth,**kw):
? ? ? ? self.name = name
? ? ? ? self.gender = gender
? ? ? ? self.birth = birth
? ? ? ? self.__dict__.update(kw)##這一句是啥意思?。?/strong>
xiaoming = Person('Xiao Ming', 'Male', '1990-1-1', job='Student')
print xiaoming.name
print xiaoming.job
2016-07-18
你在每行前后加入打印self.__dict__的值,就會發(fā)現(xiàn)其實他是把接收到的值加入到字典中。
通過字典調(diào)用值,xiaoming.job
2022-03-23
現(xiàn)在6.31可以append?//字符串等效