pygame没有出现

2024-04-28 16:23:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我最近在Python中安装了PyGame,但是发生了一些奇怪的事情。当我导入它并在终端中使用它时,它工作得很好,但是当我尝试在idle中使用它时,它根本不工作。有人知道为什么会这样吗?你知道吗

import pygame

pygame.init()

win = pygame.display.set_mode((500, 500))

退出时出错:

>Traceback (most recent call last):
  File "C:/Users/USER/PycharmProjects/Primer Python/Basico/pygame.py", line 1, in <module>
    import pygame
  File "C:\Users\USER\PycharmProjects\Primer Python\Basico\pygame.py", line 2, in <module>
    pygame.init()
AttributeError: module 'pygame' has no attribute 'init'

Tags: inpyimportinitline事情pygameusers