Discuss / Python / 作业

作业

Topic source

DeepSeaLight

#1 Created at ... [Delete] [Delete and Lock User]

/# 下面是面向对象编程思想,object oriented programming class person(object):

/# __init__就是初始化这个类person的属性property
def __init__(self,name,age,height):
    self.name = name
    self.age = age
    self.height = height
# 下面是定义你将要创建的实例的技能
def paoniu(self):
    print('你可以泡妞啦')
def eat(self):
    print('你可以吃东西啦')
def printheight(self):
    print('你的身高是: %s' % self.height)
def printname(self):
    print('%s: %s' % (self.name, self.age))

/# 下面开始创建实例 sunwukong = person('kk',18,173) /# 下面是开始使用他的技能 print(sunwukong.eat()) print(sunwukong.paoniu()) print(sunwukong.printheight()) print(sunwukong.printname())


  • 1

Reply