如何使用pyinstaller写入已打包在.exe二进制文件中的文件?

时间:2020-02-25 06:56:14

标签: python pyinstaller

我在pyinstaller中使用python 3.8.1。我已经在命令行中使用--add-data打包了文件。我想与其他人轻松共享我的程序,因此我使用了--onefile选项。我可以从文件中读取内容,但是不能追加到文件中。我正在使用

with open(resource_path("recipes.txt"),"a") as file:
        file.write(",".join(out)+"\n")
        file.write(name+"\n")
        file.close()

附加到文件。这是我的pyinstaller代码 pyinstaller --onefile -i icon.ico --add-data 'data.txt;.' .\main-text.py

我正在使用Windows 10,并且我已经知道要使用sys._MEIPASS从Adding a data file in Pyinstaller using the onefile option获取文件的绝对路径。

0 个答案:

没有答案
相关问题