主页
Python
Python 类和对象
demo_class7
运行 ❯
×
更改方向
保存代码
更改主题
class Person: def __init__(self, name, age): self.name = name self.age = age def myfunc(self): print("Hello my name is " + self.name) p1 = Person("John", 36) del p1.age print(p1.age)
Traceback (most recent call last):
File "demo_class7.py", line 13, in <module>
print(p1.age)
AttributeError: 'Person' object has no attribute 'age'