Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.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 属性错误:';非类型';对象没有属性';blit&x27;错误问题_Python_Pygame - Fatal编程技术网

Python 属性错误:';非类型';对象没有属性';blit&x27;错误问题

Python 属性错误:';非类型';对象没有属性';blit&x27;错误问题,python,pygame,Python,Pygame,我正在尝试将图像添加到屏幕,但不断出现以下错误: AttributeError:“非类型”对象没有属性“blit” 这是我的密码: import pygame pygame.init() myscreen = pygame.display.set_mode((500, 500)) myscreen = pygame.display.set_caption(("Mini game")) icon = pygame.image.load("images\space.png") pygame.di

我正在尝试将图像添加到屏幕,但不断出现以下错误:

AttributeError:“非类型”对象没有属性“blit” 这是我的密码:

import pygame

pygame.init()

myscreen = pygame.display.set_mode((500, 500))
myscreen = pygame.display.set_caption(("Mini game"))
icon = pygame.image.load("images\space.png")
pygame.display.set_icon(icon)

playerImg = pygame.image.load("player.png")
playerx = 200
playery = 200

def player():
    myscreen.blit(playerImg, (playerx, playery))

running = True

while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    player() 

错误出现在代码的前两条指令中:

myscreen=pygame.display.set_模式((500500))
myscreen=pygame.display.set_标题((“迷你游戏”))
的返回值为
None
。与窗口关联的曲面由返回,但它被覆盖,因为
pygame.display.set\u caption()
的返回值已分配给
myscreen
。它必须是:

myscreen=pygame.display.set_模式((500500))
pygame.display.set_标题((“迷你游戏”))

此外,您必须通过或以下方式更新应用程序循环末尾的显示:

导入pygame
pygame.init()
myscreen=pygame.display.set_模式((500500))
pygame.display.set_标题((“迷你游戏”))
icon=pygame.image.load(“images\space.png”)
pygame.display.set_图标(图标)
playerImg=pygame.image.load(“player.png”)
playerx=200
playery=200
def player():
blit(playerImg,(playerx,playery))
运行=真
运行时:
对于pygame.event.get()中的事件:
如果event.type==pygame.QUIT:
运行=错误
玩家()

pygame.display.flip()#错误出现在代码的前两条指令中:

myscreen=pygame.display.set_模式((500500))
myscreen=pygame.display.set_标题((“迷你游戏”))
的返回值为
None
。与窗口关联的曲面由返回,但它被覆盖,因为
pygame.display.set\u caption()
的返回值已分配给
myscreen
。它必须是:

myscreen=pygame.display.set_模式((500500))
pygame.display.set_标题((“迷你游戏”))

此外,您必须通过或以下方式更新应用程序循环末尾的显示:

导入pygame
pygame.init()
myscreen=pygame.display.set_模式((500500))
pygame.display.set_标题((“迷你游戏”))
icon=pygame.image.load(“images\space.png”)
pygame.display.set_图标(图标)
playerImg=pygame.image.load(“player.png”)
playerx=200
playery=200
def player():
blit(playerImg,(playerx,playery))
运行=真
运行时:
对于pygame.event.get()中的事件:
如果event.type==pygame.QUIT:
运行=错误
玩家()
pygame.display.flip()#