[英]I don't know why this Python Programming code doesn't work
import pygame, sys
from pygame.locals import *
pygame.init()
screen=pygame.display.set_mode((640,360),0,32)
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
screen.lock()
pygame.draw.rect(screen, (140,240,130), Rect((100,100),(130,170)))
screen.unlock()
pygame.display.update()
它應該在 640x360 的窗口中顯示一個 retangle,但它沒有這樣做,我不知道為什么它不這樣做。 請幫我。
它是這樣工作的:
你可能會有不同的表現?
以下代碼對我很有效。
#!/usr/bin/python
import pygame, sys
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((640,360),0,32)
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
screen.lock()
pygame.draw.rect(screen, (140,240,130), Rect((100,100),(130,170)))
screen.unlock()
pygame.display.update()
但是,如果您遇到任何錯誤,請分享錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.