W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
demo_python_class_7.py:
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("Bill", 63) del p1.age print(p1.age)
C:\Users\My Name>python demo_python_class_7.py
Traceback (most recent call last):
File "demo_class7.py", line 13, in <module>
print(p1.age)
AttributeError: 'Person' object has no attribute 'age'