我正在尝试从扩展类访问父成员变量。但是运行以下代码...
class Mother(object):
def __init__(self):
self._haircolor = "Brown"
class Child(Mother):
def __init__(self):
Mother.__init__(self)
def print_haircolor(self):
print Mother._haircolor
c = Child()
c.print_haircolor()
给我这个错误:
AttributeError: type object 'Mother' has no attribute '_haircolor'
我究竟做错了什么?