我已经建立了一个使用其他.txt文件在同一目录中包含银行的hangman游戏,这些是从hangman.py文件中打开的,当我使用pyinstaller打包时,我使用path\to\pyinstaller.exe hangman.py --onefile,但这不允许从可执行文件中使用.txt文件。如何打包.txt文件,以便可执行文件可以正常运行?
发布于 2019-02-24 07:14:29
您可以使用
pyinstaller --add-data 'path/to/file.txt:path/inside/exe' hangman.py或使用文件列表编辑等级库文件,即
added_files = [
( 'src/README.txt', '.' )
( '/mygame/sfx/*.mp3', 'sfx' ),
]
a = Analysis(...
datas = added_files,
...
)https://stackoverflow.com/questions/54847142
复制相似问题