python的类成员是个dict,应该如何更新?
伊谢尔伦
伊谢尔伦 2017-04-17 15:39:56
0
1
366
伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
洪涛

I don’t understand your needs. Since it is a class member variable, it needs to be bound to an instance?
Class variables are shared by all instances, instance variables only belong to the instance

class T:
    def __init__(self):
        self.d = {}
    
if __name__ == "__main__":
    
    t1 = T()
    t2 = T()
    t1.d["a"] = 1
    t2.d["b"] = 2
    print t1.d
    print t2.d
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!