【发布时间】:2019-06-12 06:53:35
【问题描述】:
每次我运行我的 python 游戏时,我都会在控制台中收到一个烦人的警告:
Hello from the pygame community. https://www.pygame.org/contribute.html
如何删除?
【问题讨论】:
标签: python python-3.x python-2.7 pygame
每次我运行我的 python 游戏时,我都会在控制台中收到一个烦人的警告:
Hello from the pygame community. https://www.pygame.org/contribute.html
如何删除?
【问题讨论】:
标签: python python-3.x python-2.7 pygame
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 的库,而不是您的用户库)
print('Hello from the pygame community ... )
如果您找不到您的库文件夹,那么您可能仍将默认设置设置为隐藏它。
在终端输入defaults write com.apple.finder AppleShowAllFiles YES;
按住选项+右键单击查找器,然后单击重新启动。
(这是未经测试的,如果您有问题,请告诉我,以便我更新)
C:\Python\Lib\site-packages\pygame 并打开_init_.py
print('Hello from the pygame community ... )
【讨论】: