python外星人代码,按书上打出来后总出现缩进错误,各位大佬这个怎么解决?

python外星人代码,按书上打出来后总出现缩进错误,各位大佬这个怎么解决?

你这个冒号看起来像是中文的啊

建议换一个代码编辑器,python的常用编辑器是pycharm,刚才我用pycharm编写了下,没报错

class Ship:
    """管理飞船的类"""
    def __int__(self,api_game):
        """初始化飞船并设置其初始位置。"""
        self.screen = api_game.screen
        self.screen_rect = api_game.screen.get_rect()
    
        # 加载飞船图像并获取其外接矩形
        self.image = pygame.image.load('images/ship.bmp')
        self.rect = self.image.get_rect()
        
        #对于每艘新飞船,都将其放在屏幕底部的中央
        self.rect.midbottom = self.screen_rect.midbottom

    def blitme(self):
        """"在指定位置绘制飞船。"""
        self.screen.blit(self.image,self.rect)

 

Python解释器有时候会发疯,有时套一个try就行了