为啥as会报错了??
main_大战外星人.py# import sys
importpygame
from Game_setting import Game_setting
from game_ship import Game_ship
from game_functions as gf
def play_game():
pygame.init()
ai_setting = Game_setting()
screen =pygame.display.set_mode((ai_setting.game_screen_with,ai_setting.game_screen_height),0,32)
pygame.display.set_caption('大战外星人游戏')
background_color =(230,230,230)#设置背景色
game_ship =Game_ship(screen)#创建一艘飞船
while True:
#监视键盘和鼠标事件
ga.check_event()
#让最近绘制的屏幕可见
screen.fill(ai_setting.backgroud_color)
game_ship.blitme()
pygame.display.flip()
play_game()
game_functions.py
import sys
import pygame
def check_event():
#响应按键和鼠标事件
for event in pygame.event.get():
if event.type== pygame.QUIT:
sys.exit()
问题::为啥as会报错了??File "C:\Users\wiecheng\Desktop\python练习\pycharm\实例\大战外星人项目\main_大战外星人.py", line 5 from game_functions as gf ^SyntaxError: invalid syntax
import,from import和import as
第五行应该是import as 第5行语法错误,你这么写试试:import game_functions as gf 应该是from xx import xx as xx这种格式,仔细审查就可以发现 from导入某个模块指定部分,后面需要加上import。 涛之雨 发表于 2021-3-30 00:25
import,from import和import as
第五行应该是import as
谢谢。。。。。
页:
[1]