我正在阅读一个关于定义函数的教程,其中包含一个创建新行的示例,您必须编写的代码是这样的:
def new_line():
print
def three_lines():
new_line()
new_line()
new_line()
def nine_lines():
three_lines()
three_lines()
three_lines()
print "hello world"
print nine_lines()
print "goodbye"
谁能解释为什么它在“再见”之前包含“无”?
最佳答案
print nine_lines()
您正在打印调用 nine_lines()
函数的结果。由于该函数不会显式返回值(使用return
语句,如果您还没有看到它,那么您很快就会看到),Python 返回特殊值无
。
要解决这个问题,只需将该行更改为
nine_lines()
关于python - 这到底有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7934181/