Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python模块问题:TypeError:';模块';对象不可调用_Python_Python 2.7_Module_Pygame - Fatal编程技术网

Python模块问题:TypeError:';模块';对象不可调用

Python模块问题:TypeError:';模块';对象不可调用,python,python-2.7,module,pygame,Python,Python 2.7,Module,Pygame,我一直在尝试用Python(和PyGame)开发一个文本冒险类型的游戏,因此需要一个模块来反复将文本blit到屏幕上。在搜索了一些之后,我下载了KTextSurfaceWriter并安装了它。然后我试着按照这里提供的文本中的演示() 我的代码: from ktextsurfacewriter import KTextSurfaceWriter import pygame from pygame.locals import * import pygame.font pygame.font.ini

我一直在尝试用Python(和PyGame)开发一个文本冒险类型的游戏,因此需要一个模块来反复将文本blit到屏幕上。在搜索了一些之后,我下载了KTextSurfaceWriter并安装了它。然后我试着按照这里提供的文本中的演示()

我的代码:

from ktextsurfacewriter import KTextSurfaceWriter

import pygame
from pygame.locals import *
import pygame.font
pygame.font.init()
screen = pygame.display.set_mode((640,480), 0, 32)

surface = pygame.surface ( (400, 400), flags = SRCALPHA, depth = 32)
surface.fill( (255,255,255,255) )

def blitSurface():
    screen.blit(surface, (50,50) )
    pygame.display.update()

blitSurface()

def waitForUserAction():
    while True:

        for event in pygame.event.get():
            if event.type == QUIT:
                import sys
                sys.exit()
            if event.type == KEYDOWN:
                return

waitForUserAction()

但是,这会在第9行抛出模块错误。我对Python相当陌生,我看到的关于这个问题的大多数解决方案都涉及到使用“from[module]import”代码,我在一开始就已经有了这些代码。

您正在调用
pygame.surface
模块:

surface = pygame.surface ( (400, 400), flags = SRCALPHA, depth = 32)

使用
pygame.surface.surface()
或使用
pygame.surface()
(注意大写字母
S
);这两个类都是相同的,但都是pygame。surface是定义它的模块。

您正在调用pygame。surface模块:

surface = pygame.surface ( (400, 400), flags = SRCALPHA, depth = 32)

使用
pygame.surface.surface()
或使用
pygame.surface()
(注意大写字母
S
);这两个类都是同一个类,但都是pygame。surface是定义它的模块。

我看过你的代码和源代码

surface = pygame.surface ( (400, 400), flags = SRCALPHA, depth = 32)
在您的代码中,“surface”是小写的,这是一个python模块,因此python解释器告诉您err msg

surface = pygame.Surface( (400,400), flags=SRCALPHA, depth=32 )

在源代码中,“Surface”是大写字母,可能是一个类。

我看过你的代码和源代码

surface = pygame.surface ( (400, 400), flags = SRCALPHA, depth = 32)
在您的代码中,“surface”是小写的,这是一个python模块,因此python解释器告诉您err msg

surface = pygame.Surface( (400,400), flags=SRCALPHA, depth=32 )

在源代码中,“Surface”是capital,它可能是一个类。

您是否想到capital Surface?Python是区分大小写的。你在考虑capital Surface吗?Python是区分大小写的。我想我还不习惯Python的大小写区分。谢谢你的帮助!我想我还不习惯Python的大小写敏感度。谢谢你的帮助!