在交互式环境中输入:
1 >>> class A: 2 a=0 3 def __init__(self): 4 self.a=10 5 self.b=100 6 7 8 >>> a=A() 9 >>> a.a10 1011 >>> a.b12 10013 >>> A.a14 015 >>> A.b16 Traceback (most recent call last):17 File "<pyshell#10>", line 1, in <module>18 A.b19 AttributeError: type object 'A' has no attribute 'b'20 >>>
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did82030