为什么在导入pygame时会出现消息,它会打印版本和欢迎消息.消息显示
"pygame 1.9.4 Hello from the pygame community.
https://www.pygame.org/contribute.html"
Run Code Online (Sandbox Code Playgroud)
如何禁用此消息?
我想知道是否print可以覆盖内置函数,以便以下语句将同时写入控制台和文件.
print("test0","test1","test2",sep='\n')
Run Code Online (Sandbox Code Playgroud)
另外,我可以知道是否可以修改内置print函数的源代码?
当我运行程序时,使用的是:
nltk.download('wordnet')
from nltk.corpus import wordnet
Run Code Online (Sandbox Code Playgroud)
我将以下输出发送到终端:
[nltk_data] Downloading package wordnet to
[nltk_data] /Users/.../nltk_data...
[nltk_data] Package wordnet is already up-to-date!
Run Code Online (Sandbox Code Playgroud)
我的程序依赖于未将此信息保存到终端和结果输出文件中,因此,如何防止上述行发生或将其写入,以sys.stderr使其不被包含而不是通过传递print呢?