首页 > IT职业 > IT职场 > python面向对象
class Person(object):
# age = ""
# height = 0
def run(self):
print("pao")
def chi(self,food):
print("%s吃%s"%(self.name, food))
#构造
def __init__(self, name, age, height):
self.name = name
self.age = age
self.height = height
self.__money = 5000 #访问限制
def SetMoney(self, num):
if num per1 = Person("tom",12,168)
print(per1.name)
per1.chi("apple")
per1.SetMoney(4)
print(per1)
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3974/viewspace-2802379/ ,如需转载,请注明出处,否则将追究法律责任。