Python pygame screen.fill() 设置颜色不显示

import sys
import pygame
screen = pygame.set_mode((900,600))
while True:
       for event in pygame.event.get()
             if event.type == pygame.QUIT:
                 sys.exit()
screen.fill((135,206,250))
pygame.display.flip()

尝试过其他数值 运行窗口还是黑色
环境 Windows 11
pygame 2.1.3.dev8 (SDL 2.0.22,Python 3.11.0)

img

望采纳


在 pygame 中,pygame.Surface.fill() 方法可以用于设置窗口的背景颜色。你需要将它放在 pygame.display.flip() 方法之前,否则它不会生效。