创建类时发生AttributeError

时间:2018-09-13 17:38:51

标签: python-3.x class attributeerror

这是我不知道的简单方法。创建此类时我做错了什么? AttributeError发生在以下行:print(lunaLovegood.height_inches,'in,',end ='')

class PatientData:
    def __init__(self):
        height_inches = 0
        weight_pounds = 0


lunaLovegood = PatientData()
print('Patient data (before):', end=' ')
print(lunaLovegood.height_inches, 'in,', end=' ')
print(lunaLovegood.weight_pounds, 'lbs')


lunaLovegood.height_inches = 63
lunaLovegood.weight_pounds = 115

print('Patient data (after):', end=' ')
print(lunaLovegood.height_inches, 'in,', end=' ')
print(lunaLovegood.weight_pounds, 'lbs')

0 个答案:

没有答案