所以我剛剛完成了大量的學習python和學習pygame。所以我這個免費的在線圖書沿以下,並在書中使用的hello world窗口頂部的代碼的第一件事就是給我一個錯誤:Python pygame IndentationError
繼承人的代碼:
import pygame, sys
from pygame.locals import *
pygame.init()
DISPLAYSURF = pygame.display.set_mode((400, 300))
pygame.display.set_caption('Hello World!')
while True: # main game loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
繼承人錯誤:
File "pygame.py", line 9
if event.type == QUIT:
^
IndentationError: expected an indented block
在此先感謝!
這段代碼在我的結尾工作正常。你確定所有的標識都是空格或製表符嗎? – gkso
可能的重複[爲什麼我會得到「IndentationError:期望的縮進塊」?](http://stackoverflow.com/questions/4446366/why-am-i-getting-indentationerror-expected-an-indented-block) –