我开始使用 Python 特别是 pygame 模块,但是当我尝试创建一个窗口时,会发生此错误
>>> import pygame
>>> (width, height) = (300, 200)
>>> screen = pygame.display.set_mode((width, height))
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
screen = pygame.display.set_mode((width, height))
AttributeError: module 'pygame' has no attribute 'display'
请帮帮我。
您可能会用任何其他同名文件(例如可能位于同一文件中的 pygame.py )掩盖 pygame 库
如果您使用的是 Windows,只需在开始菜单的搜索框中搜索 pygame.py 即可。右键单击结果,然后单击“打开文件位置”。只需从文件夹中删除 pyagame.py 文件即可。
或者您可以通过以下方式打印有问题的模块的路径:
import pygame
print('Path to module:',pygame._file_)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)