问题描述
正如标题所述,python中的print()函数是void函数吗?
As the title says, is the print() function in python a void function?
我认为print()函数返回并打印到屏幕上并传递给它.现在,我考虑了一下,似乎它什么也没有返回,并且确实是一个void函数.有人可以帮我验证一下吗?预先感谢!
I thought the print() function returns and prints to screen what is passed into it. Now that I think about it, it seems like it doesn't return anything and is indeed a void function. Can someone verify this for me please? Thanks in advance!
我尝试了以下操作:
some_variable = print()
print(some_variable)没有
推荐答案
它不返回值,与返回None相同.您不会在文档中明确找到它,因为返回None的函数只是省略了记录返回值的记录.
It does not return a value, which is the same as returning None. You won't find it explicitly in the documentation as functions returning None simply omit documenting the return value.
这篇关于python中的print()函数是否被视为void函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!