我必须从我的 python 程序生成一个可执行 (.exe) 文件。我想在这个 .exe 文件本身中以持久的方式存储信息。
通常我会将它刺入外部文件,但对我来说,重要的是信息存储在 .exe 文件本身而不是外部文件中。
提前致谢!
If you want read-write data:
Don't do this. An executable changing itself isn't guaranteed to work. Some executables write data at the end of the file (in theory) but you don't know:
[Nearly] all software is able to get by with 'normal' file storage (i.e. in a user / application data directory).
If you just want read-only data:
Fine, no problem. Write a Python file with the data in it, as a variable in a module. You can write a python file as part of your build process.