class dav():
def d1():
bit=1
bit1=0
p1=dav()
print(p1.d1.bit)
print语句引发AttributeError
:
AttributeError: 'function ' object has no attribute 'bit1'
答案 0 :(得分:1)
class dav(object):
def __init__(self):
self.bit=1
self.bit1=0
p1=dav()
print(p1.bit)
可能是你的意思......