.DokiDoki

导航

python 在终端输出如下信息

在终端输出如下信息‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬

  • 小明,10岁,男,上山去砍柴
  • 小明,10岁,男,开车去东北
  • 小明,10岁,男,最爱打游戏
  • 老李,90岁,男,上山去砍柴
  • 老李,90岁,男,开车去东北
  • 老李,90岁,男,最爱打游戏
  • 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, '')

     

  • 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()

     

posted on 2020-10-26 19:26  .DokiDoki  阅读(246)  评论(0编辑  收藏  举报