Pygame 属性,init() [英] Pygame attribute, init()

查看:81
本文介绍了Pygame 属性,init()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 Windows 8 笔记本电脑上使用 Pygame 和 Python 3.3.Pygame 安装得很好,当我 import pygame 时,它也能很好地导入.虽然当我尝试执行这个小代码时:

I'm trying to use Pygame with Python 3.3 on my windows 8 laptop. Pygame installed fine and when I import pygame it imports fine as well. Although when I try to execute this small code:

import pygame

pygame.init()

size=[700,500]
screen=pygame.display.set_mode(size)

我收到此错误:

Traceback (most recent call last):
  File "C:\Users\name\documents\python\pygame_example.py", line 3, in <module>
    pygame.init()
AttributeError: 'module' object has no attribute 'init'

我使用 pygame-1.9.2a0-hg_56e0eadfc267.win32-py3.3 来安装 Pygame.Pygame 安装在此位置C:\PythonX",Python 3.3 安装在此位置C:\Python33".我看过其他有相同或类似问题的人,但似乎并没有解决错误.安装 Pygame 时我做错了什么吗?还是不支持windows 8?

I used pygame-1.9.2a0-hg_56e0eadfc267.win32-py3.3 to install Pygame. Pygame is installed in this location 'C:\PythonX' and Python 3.3 is installed in this location 'C:\Python33'. I have looked at other people having the same or similar problem and it doesn't seem to solve the error. Have I done anything wrong when installing Pygame? Or does it not support windows 8?

推荐答案

之后导入pygamepygame.init()

After import pygame pygame.init()

我收到此错误消息并且程序不起作用:" AttributeError: 模块 'pygame' 没有属性 'init' "

I got this error message and programm didnt work: " AttributeError: module 'pygame' has no attribute 'init' "

因为我将文件命名为pygame.py"...

because i named the file "pygame.py"...

当我将文件名更改为pygametest.py"时,一切正常.

When i chaned filename to "pygametest.py" everything worked.

完全像模块名一样命名文件名似乎混淆了python...

Naming the filename exactly like the modulename seems to confuse python...

这篇关于Pygame 属性,init()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆