Tôi đang cố truy cập biến thành viên chính từ một lớp mở rộng. Nhưng chạy đoạn mã sau ...Không thể truy cập biến thành viên cha trong Python
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()
Gets tôi lỗi này:
AttributeError: type object 'Mother' has no attribute '_haircolor'
Tôi đang làm gì sai?
thanks- im một thằng ngốc – Yarin