终端输出

def kanchai(name, age, gender):
print("%s,%s岁,%s,上山去砍柴" %(name, age, gender))

def qudongbei(name, age, gender):
print("%s,%s岁,%s,开车去东北" %(name, age, gender))

def dabaojian(name, age, gender):
print("%s,%s岁,%s,最爱打游戏" %(name, age, gender))

kanchai('小明', 10, '男')
qudongbei('小明', 10, '男')
dabaojian('小明', 10, '男')

kanchai('老李', 90, '男')
qudongbei('老李', 90, '男')
dabaojian('老李', 90, '男')

终端输出

 

 

class Foo:
def __init__(self, name, age ,gender):
self.name = name
self.age = age
self.gender = gender
def kanchai(self):
print("%s,%s岁,%s,上山去砍柴" %(self.name, self.age, self.gender))
def qudongbei(self):
print("%s,%s岁,%s,开车去东北" %(self.name, self.age, self.gender))
def dabaojian(self):
print("%s,%s岁,%s,最爱打游戏" %(self.name, self.age, self.gender))

xiaoming = Foo('小明', 10, '男')
xiaoming.kanchai()
xiaoming.qudongbei()
xiaoming.dabaojian()
laoli = Foo('老李', 90, '男')
laoli.kanchai()
laoli.qudongbei()
laoli.dabaojian()

终端输出

 

上一篇:Spring的学习1(IOC使用XML配置文件的基本使用)


下一篇:C#-笔记-面向对象-第二章