我刚开始学习Python和我刚刚被搞乱各地的实践中学习打字不同的代码,和我做了这个代码:Python的参数和功能
import math
def lol():
print (math.cos(math.pi))
print ("I hope this works")
def print_twice(bruce):
print bruce
print bruce
print_twice(lol())
当我运行它,我的输出是:
-1.0
I hope this works
None
None
为什么不是两次打印函数lol()?
我应该如何改变它,所以它会打印两次?而不是返回无无。是否因为函数在print_twice(lol())中第一次被调用时会终止? –
在上面编辑了更正确的版本。 –