一个小小的python的疑问,初学者
学着教程的例子,自己写了一个关于python中property属性的使用的代码见下面:
__meteclass__ = typeclass people: def __init__(self,name,age,height): self.name = name self.age = age self.height = height def getAtt(self): return self.name,self.age,self.height def setAtt(self,att): self.name,self,age,self.height = att att = property(getAtt,setAtt)p = people("dengchao",24,170)print p.attp.att = "dengchao",24,175print p.attattr = ("deng",22,179)#p.setAtt(("deng",22,179))#p.setAtt(attr)p.att = attrprint p.att
self.name,self,age,self.height = att
[解决办法]
self.name,[color=#FF0000]self,age[/color],self.height = att
[解决办法]
4楼我已经提示了,你要用新式类,也就是去继承object...