python 导入cfg模块使用时报错

python 中导入cfg模块,在代码中使用时提示:“AttributeError: module 'cfg' has no attribute 'SCREENSIZE'”

这段代码是网上的

代码片段

import os
import sys
import pygame
import cfg
from modules import *
 
 
'''游戏主程序'''
def main():
    pygame.init()
    screen = pygame.display.set_mode(cfg.SCREENSIZE)
    pygame.display.set_caption('Gemgem —— 九歌')
    # 加载背景音乐
    pygame.mixer.init()
    pygame.mixer.music.load(os.path.join(cfg.ROOTDIR, "resources/audios/bg.mp3"))
    pygame.mixer.music.set_volume(0.6)
    pygame.mixer.music.play(-1)

报错内容:

ws001@WSdeMacBook-Pro Desktop % python3 demo01.py
pygame 2.1.0 (SDL 2.0.16, Python 3.10.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "/Users/ws001/Desktop/demo01.py", line 67, in <module>
    main()
  File "/Users/ws001/Desktop/demo01.py", line 11, in main
    screen = pygame.display.set_mode(cfg.SCREENSIZE)
AttributeError: module 'cfg' has no attribute 'SCREENSIZE'

pyton版本:Python 3.10.5

cfg 版本:cfg2-0.2b0

pygame版本:pygame-2.1.0

https://ask.csdn.net/questions/7917189

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^