学习类了,头有点疼
class Person():def __init__(self,name,age,like):
self.__name = name
self.age = age
self.like = like
def my_self(self):
return f"大家好,我叫{self.__name},我今年{self.age}岁了,我的爱好是{self.like}。"
def jump(self,h=1):
return f"我能跳{h}米高!"
def __del__(self):
print(f"{self.__name}不存在了。")
def __repr__(self):
return f"姓名:{self.__name} 年龄:{self.age} 爱好:{self.like}"
jhz = Person("jhz",5,"玩乐高") 这也算简单的了
class Person:
class Body:
@staticmethod
def __getitem__():
return Person.Body
页:
[1]