如何解决我执行错误后立即关闭窗口?
这就是我的代码:我已经在Python 3.8,3.7.6中进行了尝试。 它打开窗口并立即关闭它。 此外,它还显示一个错误:
if event.type == pygame.QUIT(): TypeError: 'int' object is not callable
import pygame
#initialize the pygame
pygame.init()
#create the screen
screen = pygame.display.set_mode((800,600))
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT():
running = False
解决方法
pygame.QUIT
是一个枚举数常量,不可调用:
(请参见pygame.event模块)
if event.type == pygame.QUIT():
if event.type == pygame.QUIT:
,
您的代码包含错误
第13行,在 如果event.type == pygame.QUIT():TypeError:“ int”对象不可调用
退出是不可调用的,它是属性,请执行以下操作:
if event.type == pygame.QUIT:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。