为什么我的Python可执行文件无法创建文件,但可以在运行时访问数据?
一点点上下文:
- 我在Python中制作了密码管理器,
- 然后将其包装成一个可执行文件:
pyinstaller -onefile password_manager.py
好的,首先,我想指定脚本在我通过password_manager.py文件运行时,脚本正常工作,可执行版本也可以正常运行,并且当我创建用户并创建用户和我将数据保存在新的JSON文件中。我可以在运行时访问它,但是当我实际关闭外壳并且程序停止运行时,它就像数据都丢失或删除一样。我正在寻找一种方法,让所需的数据像我单独运行password_manager.py时一样保留在我的驱动器上。
PS 我也可以在计算机中查看隐藏的文件。
PSS 代码的链接在此处:代码
我的
net/soofo.png“ rel =“ nofollow noreferrer”> data 我最近在没有关闭和重新启动程序的情况下添加了。这些信息应该存储在/data/users.json和 /data /passwork中(并且在我只使用password_manager.py时存储在此处)可执行文件(既不应该创建的目录也不是文件)。
简单复制:
#mkdir.py
import os
os.mkdir("stack")
Shell:
pyinstaller --onefile mkdir.py
我也很可悲地找不到将可执行文件包含在此问题中的方法,但是您可以用给定的命令将其复制。
A little bit of context:
- I have made a password manager in python
- I then packed it into a single executable using:
pyinstaller --onefile password_manager.py
Okay first I want to specify that the script works properly when I run it through the password_manager.py file, the executable version also runs properly and when I e.g. create a user and I save the data in a new json file. I'm able to access it on runtime but when I actually close the shell and the program stops running it's like the data has all been lost and or deleted. I'm looking for a way for the required data to remain on my drive like they do when I run password_manager.py on its own.
P.S.
I can view hidden files in my computer too.
P.S.S.
The link to the code is here: code
My file structure when I run it through password_manager.py
Here is the executable showing some random Data I recently added without closing and restarting the program. These information was supposed to be stored in /data/users.json and /data/password (and is stored there when I just use password_manager.py) but when I actually exit the application they are not present in any way when I rerun the executable(neither the directories that were supposed to be created nor the files).
Simple replication:
#mkdir.py
import os
os.mkdir("stack")
shell:
pyinstaller --onefile mkdir.py
I also sadly couldn't find a way to include the executable in this question but you can replicate it with the given command.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论