简体   繁体   中英

Store information into .exe file, exported from python

I have to generate an executable (.exe) file from my python program. I would like to store information in a persistent way within this .exe file itself.

Normally I would prickel it into an external file, however for me it is important that the information is stored in the .exe file itself and not externally.

Thanks in advance!

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:

  • whether antivirus software will pick this behaviour up as part of behavioural analysis
  • whether the executable is actually writable from the executable process
  • whether data you write might become executable in theory and result in a security exploit
  • whether you'll want to update a new release to the code next week, which will replace the executable file and lose the data

[Nearly] all software is able to get by with 'normal' file storage (ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM