这个图片加载不出来
import sys
import pygame
def main():
#初始化
pygame.init()
width,height=480,852
#屏幕对象
screen=pygame.display.set_mode((width,height))
#设置窗口的标题
pygame.display.set_caption('飞机大战_帅逼余金灿编写')
#加载背景图片
bg=pygame.image.load('./assets/images/background.png')
while True:
#1.监听事件
for event in pygame.event.get():
#退出游戏
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
#更新游戏的状态
#回执
screen.blit(bg,bg.get_rect())
pygame.display
main()报错提示:
Traceback (most recent call last):
File "C:/Users/Think/PycharmProjects/feijidazhan/store/main.py", line 30, in <module>
main()
File "C:/Users/Think/PycharmProjects/feijidazhan/store/main.py", line 17, in main
bg=pygame.image.load('assets/images/background.png')
pygame.error: Couldn't open assets/images/background.png
还有有一个很奇怪的,我一打__双下划线就会变成_ _这样子,不知道咋回事
正在回答 回答被采纳积分+1

就是打出来是这个样子
用后面老师的方法base dir那个后还是报错:
Traceback (most recent call last):
File "C:/Users/Think/PycharmProjects/feijidazhan/store/main.py", line 5, in <module>
from store.constants import BG_IMG
File "C:\Users\Think\PycharmProjects\feijidazhan\store\constants.py", line 6
ASSETS_DIR = os.path.join(BASE_DIR,'assets')
^
SyntaxError: invalid syntax
相似问题
登录后可查看更多问答,登录/注册
- 参与学习 人
- 提交作业 2727 份
- 解答问题 8160 个
想要进入Python Web、爬虫、人工智能等高薪领域,你需要掌握本阶段的Python基础知识,课程安排带你高效学习轻松入门,学完你也能听得懂Python工程师的行业梗。
了解课程




恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星