python報錯:
Traceback (most recent call last):
File "C:\Users\LENOVO\Desktop\pg.py", line 5, in <module>
from settings import Settings
ModuleNotFoundError: No module named 'settings'
settings檔案和源檔案都有,為什么報錯說沒有settings檔案?
以下是代碼
pg.py:
import sys
import pygame
from settings import Settings
def run_game():
#初始化生成游戲并創建一個螢屏物件
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode(
(ai_settings.screen_width,ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
bg_color = (230,230,230)
#開始游戲的主回圈
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
screen.fill(ai_settings.bg_color)
pygame.display.flip()
run_game()
以下是settings的代碼
settings.py:
class Settings():
def _init_(self):
self.screen_width=1200
self.screen_hight=800
self.bg_color = (230,230,230)
麻煩教導一下,謝謝
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/62277.html
標籤:其他開發語言
上一篇:為啥這個DATA1DB 33H,39H,31H,37H是定義的十進制呀
下一篇:Word圖片編輯退出問題
