【发布时间】:2021-02-20 10:19:24
【问题描述】:
这是我的第一个问题!我只是在学习如何用 Python 编写代码,所以不要对我太苛刻。
我在 Python 中编写了以下类,当我调用方法 describe_restaurant(位于父类中)时,我在描述之后立即得到这个“无”输出。
我无法弄清楚为什么会发生这种情况,也无法摆脱这个“无”输出。
这是我的代码图片:
感谢您对这么糟糕的问题的帮助!
【问题讨论】:
-
将任何代码/错误添加为格式化为代码而非图像的文本。检查Why not upload images of code/errors when asking a question?
-
不要用
describe_restaurant()调用print(),因为describe_restaurant()默认返回None,因为没有返回任何内容,因此您可以打印print(None)和None。就做my_iceCreamStand.describe_restaurant()