简体   繁体   中英

from compile co_code back to executable is there any way to convert your python program to a hexadecimal string and back?

Is there any way in python to transform co_code back to the outcome of compile? I would like to store my program in an hexadecimal string so that i can compare that each node in the network runs the same program Or can we execute co_code with something like exec?

from json import loads, dumps
from binascii import unhexlify
with open('compile.py') as c:
    sjfhg = bytes(c.read().encode()).hex()
    exec(compile(unhexlify(sjfhg).decode(), '', 'exec'))

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