鱼C论坛

 找回密码
 立即注册
查看: 1077|回复: 4

[已解决]来自初学者的一个小问题

[复制链接]
发表于 2020-5-18 22:05:24 | 显示全部楼层 |阅读模式
10鱼币
这段代码如何调试运行。。。
  1. import types
  2. class Person(object):
  3.     def __init__(self,name):
  4.         assert isinstance(name,str),('name must be string')
  5.         self.name=name
  6.     def sing(self):
  7.         print(self.name+'can sing')
  8.     def walk(self):
  9.         print(self.name+'can walk')
  10.     def eat(self):
  11.         print(self.name+'can eat.')
复制代码
最佳答案
2020-5-18 22:05:25
这样即可:
  1. import types
  2. class Person(object):
  3.     def __init__(self,name):
  4.         assert isinstance(name,str),('name must be string')
  5.         self.name=name
  6.     def sing(self):
  7.         print(self.name+'can sing')
  8.     def walk(self):
  9.         print(self.name+'can walk')
  10.     def eat(self):
  11.         print(self.name+'can eat.')

  12. p = Person('香蕉君')
  13. p.sing()
  14. p.walk()
  15. p.eat()
复制代码



如果帮助到你记得给个最佳~

最佳答案

查看完整内容

这样即可: [hr] 如果帮助到你记得给个最佳~
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-5-18 22:05:25 | 显示全部楼层    本楼为最佳答案   
这样即可:
  1. import types
  2. class Person(object):
  3.     def __init__(self,name):
  4.         assert isinstance(name,str),('name must be string')
  5.         self.name=name
  6.     def sing(self):
  7.         print(self.name+'can sing')
  8.     def walk(self):
  9.         print(self.name+'can walk')
  10.     def eat(self):
  11.         print(self.name+'can eat.')

  12. p = Person('香蕉君')
  13. p.sing()
  14. p.walk()
  15. p.eat()
复制代码



如果帮助到你记得给个最佳~

评分

参与人数 1荣誉 +5 鱼币 +5 贡献 +3 收起 理由
Cria + 5 + 5 + 3

查看全部评分

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-5-18 22:07:05 | 显示全部楼层
f5
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2020-5-18 22:20:07 | 显示全部楼层

老哲学家了
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-5-18 22:20:48 | 显示全部楼层

被发现了哈哈
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-19 20:17

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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