每次运行我的Python游戏,控制台都会出现一个烦人的警告:
Hello from the pygame community. https://www.pygame.org/contribute.html
我该如何删除它?
Hello from the pygame community. https://www.pygame.org/contribute.html
我该如何删除它?
修改库意味着你需要在发送代码的所有地方都修改库,通常不是一个好主意。
pygame即将发布的版本1.9.5
将包括一个选项来关闭消息而无需修改库:
您必须将环境变量PYGAME_HIDE_SUPPORT_PROMPT
设置为任何值。
在Windows上:set PYGAME_HIDE_SUPPORT_PROMPT=1
在Linux等系统上:export PYGAME_HIDE_SUPPORT_PROMPT=1
甚至可以在您的代码中:
from os import environ
environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'
import pygame # it is important to import pygame after that
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pygame/
并打开 _init_.py
(提示:这是您的 Macintosh HD 的 Library,而不是您的用户 library)
print('Hello from the pygame community ... )
如果找不到 Library 文件夹,则可能仍然将默认设置隐藏。
在终端中键入defaults write com.apple.finder AppleShowAllFiles YES;
按住 Option 键并右键单击 Finder,然后单击重新启动。
(未经测试,如有问题请告知以便更新)
C:\Python\Lib\site-packages\pygame
并打开 _init_.py
print('Hello from the pygame community ... )