鱼C论坛

 找回密码
 立即注册
查看: 1162|回复: 3

类的实例

[复制链接]
发表于 2020-5-16 16:33:29 | 显示全部楼层
本帖最后由 Twilight6 于 2020-5-16 16:35 编辑

没有设置return 所以就会自动返回None了
  1. class Restrunt():
  2.     def __init__(self, name, type):
  3.         self.name = name
  4.         self.type = type
  5.         self.number = 0

  6.     def guess(self):
  7.         person = (self.name + self.type)
  8.         return person

  9.     def mouve(self):
  10.         return '这家餐馆是做' + self.type + 'de' + '\n他的名字叫做' + self.name

  11.     def omder(self):
  12.         return '共有' + str(self.number) + '个人在此就餐过'


  13. resun = Restrunt('和平饭馆', '家常菜')
  14. print(resun.guess())
  15. print(resun.mouve())
  16. print(resun.omder())
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-25 03:08

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表