标签: python python-3.x
设置这样一个最小的代码:
class Dog: kind = 'canine' def __init__(self, name): self.name = name class TestDog(Dog): print(kind)
错误来了:
NameError: name 'kind' is not defined
由于类属性kind是普遍继承的,因此 为什么会报告NameError?
kind