PyCharm 在 PyGame __initi__.py 中找不到参考?

PyCharm can't find reference in PyGame __initi__.py?

好的,我对编码很陌生,我只是在学习 Python。我想我会从一些基本的 Pygame 练习开始,尝试编写一些东西。

我已经安装了 Python 3.4.3 和 PyCharm。我还从这里安装了 Pygame 可执行文件“pygame-1.9.2a0-hg_5974ff8dae3c+.win32-py3.4.msi”:https://bitbucket.org/pygame/pygame/downloads

我 运行 Pygame 安装程序,它似乎完成时没有明显的问题,尽管我的桌面上没有明显的迹象,比如新的快捷方式。

然后我去这里尝试一些涉及Pygame的基本测试代码: http://pythonprogramming.net/pygame-python-3-part-1-intro/

所以我将该示例中的代码复制到我的 Pycharm 中,然后 运行 它。它似乎创建了一个空白 Pycharm windows 好吧,但是 PyCharm 代码检查器给了我几个警告,我真的很想知道为什么我会收到这些警告。

第一个 Pycharm 警告来自第 5 行,“在‘__init__.py’中找不到引用‘init’” 下一个警告是第 16 行,“在‘__init__.py’中找不到引用‘QUIT’” 第三个也是最后一个警告是第 24 行,“Cannot find reference ‘quit’ in ‘__init__.py

为什么找不到这些引用?怎么了?

我粘贴在下面的代码本身:

#! /usr/bin/python

import pygame

pygame.init()

gameDisplay = pygame.display.set_mode((800, 600))
pygame.display.set_caption('A bit Racey')
clock = pygame.time.Clock()

crashed = False

while not crashed:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            crashed = True

        print(event)

    pygame.display.update()
    clock.tick(60)

pygame.quit()
quit()

这对你没有错误...导入系统并执行系统退出

#! /usr/bin/python

import pygame
import sys

pygame.init()

gameDisplay = pygame.display.set_mode((800, 600))
pygame.display.set_caption('A bit Racey')
clock = pygame.time.Clock()

crashed = False

while not crashed:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            crashed = True

        print(event)

    pygame.display.update()
    clock.tick(60)

pygame.quit()
sys.exit()