python ai_game未定义

bd1hkmkf  于 2022-12-28  发布在  Python
关注(0)|答案(1)|浏览(167)

This is what happened when I was doing p.233, Chapter 12, Python Crash Course 2nd.I am using Visual Studio Code to write the python codes. Here is what I got. I can not proceed at this point. Can someone tell me how to fix this problem? It seems to me that some folks don't have such a problem because their code writers happen to default on defining ai_game. Unfortunately, this doesn't happen on me.
好吧,这是我学习Python的第二个星期了。这简直要了我的命!一开始我试着导入ai_game,但VSC告诉我Python中没有这样的模块。我猜在写ship.py之前定义ai_game会怎样。但是你看,我显然是个新手,不知道我应该寻求解决方案的正确方向。所以保存我吧。

jk9hmnmh

jk9hmnmh1#

请按如下方式导入pygame

import pygame as pg

代码应类似于..

import pygame as pg

class Ship:    
  def _init_(self, ai_setting):
    # initialize
    pg.init()
    resolution = 400, 200
    screen = pg.display.set_mode(resolution)
    self.screen_rect = screen.get_rect()
  ........

相关问题