AttributeError问题
class Washer():def _init_(self):
self.width = 500
self.height = 800
def print_into(self):
print(f'洗衣机的高度是{self.height}')
print(f'洗衣机宽度是{self.width}')
haier = Washer()
haier.print_into()
AttributeError: 'Washer' object has no attribute 'height'
求大家帮帮忙,我又错在哪了 init用双下划线
class Washer():
def __init__(self):
self.width = 500
self.height = 800
def print_into(self):
print(f'洗衣机的高度是{self.height}')
print(f'洗衣机宽度是{self.width}')
haier = Washer()
haier.print_into()
楼上正解
页:
[1]