class A: Y = 5 def __init__(self): self.x = 5 a = A() setattr(A,'y',10) print(A.__dict__) print(a.__dict__) print(getattr(a,'x')) print(getattr(a,'y')) if hasattr(a,'z'): print(getattr(a,'z')) setattr(a,'y',1000) print(A.__dict__) print(a.__dict__) print(getattr(a,'y')) print(getattr(A,'y')) # print(hasattr(a,'z')) setattr(A,'mtd',lambda self : 1) print(A.__dict__) print(a.__dict__) print(a.mtd()) print(A.Y)
初级程序员
by: 江湖夜雨 发表于:2021-02-05 18:06:14 顶(0) | 踩(0) 回复
这个程序没有看懂,不知道要干什么
回复评论