Python | pygame.mixer.music.load()函数使用相对路径
程序员文章站
2022-03-02 23:26:56
...
import os,sys
APP_FOLDER = os.path.dirname(os.path.realpath(sys.argv[0]))
# method one
full_path=os.path.join(APP_FOLDER,"your_file_name")
pygame.mixer.music.load(full_path)
# method two: change current working directory
os.chdir(APP_FOLDER)
pygame.mixer.music.load('your_file_name')