亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

IndentationError 但它沒有混淆制表符和空格

IndentationError 但它沒有混淆制表符和空格

ITMISS 2023-04-25 17:15:29
當我嘗試運行我的腳本時,它堅持認為第 10 行有一個 IndentationError,即 def init (self): 行。查找它我嘗試了一些我見過的常見修復,檢查以確保制表符和空格沒有混淆,確保循環結構正確,但沒有任何效果!import sysimport pygamefrom settings import Settingsfrom ship import Shipclass AlienInvasion:  """Overall game assets and behavior"""        def __init__(self):        """Initialize the game, and create game resources"""        pygame.init()                self.settings = Settings()pi        self.screen = pygame.display.set_mode((self.settings.screen_width, self.settings.screen_height))        pygame.display.set_caption("Alien Invasion")        self.ship = Ship(self)        # Set the background        self.bg_color = (230, 230, 230)    def run_game(self):        """Start the main loop for the game"""        while True:            # Watch for keyboard and mouse events.            for event in pygame.event.get():                if event.type == pygame.QUIT:                    sys.exit()                # Redraw the screen during each pass through the pass                self.screen.fill(self.settings.bg_color)                self.ship.blitme()            # Make the most recently drawn screen visible            pygame.display.flip()if __name__ == '__main__':    # Make a game instance, and run the game    ai = AlienInvasion()    ai.run_game()如果有人能告訴我發生了什么,將不勝感激。在我的編碼生涯這么晚的時候嘗試使用 Python 是一件很麻煩的事情。
查看完整描述

1 回答

?
皈依舞

TA貢獻1851條經驗 獲得超3個贊

這:


class AlienInvasion:

  """Overall game assets and behavior"""

應該是這樣的:


class AlienInvasion:

    """Overall game assets and behavior"""

以便它匹配下一個定義:


    def __init__(self):


查看完整回答
反對 回復 2023-04-25
  • 1 回答
  • 0 關注
  • 131 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號