简体   繁体   English

Pygame程序无法正确执行

[英]Pygame program not executing properly

When i run this pygame program, a window is supposed to pop up, but nothing happens. 当我运行这个pygame程序时,应该弹出一个窗口,但是什么也没有发生。 Am i doing something wrong? 难道我做错了什么?

import pygame

pygame.init()

win = pygame.display.set_mode((500,500))

The problem here is that the program ends and closes the window. 这里的问题是程序结束并关闭窗口。 You should create some sort of game loop to keep the window open. 您应该创建某种游戏循环来保持窗口打开。 An easy fix is to use an infinite while loop after the last line. 一个简单的解决方法是在最后一行之后使用无限while循环。

import pygame

pygame.init()

win = pygame.display.set_mode((500,500))

while True:
    pass

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM