I have a .pyc file with code:
def myfunc(in_str = "Hello World"):
print(in_str)
I try to run it from a separate code like this:
import marshal
s = open('script2.cpython-37.pyc', 'rb')
s.seek(12) # Also tried s.seek(8) here
code_obj = marshal.load(s)
exec(code_obj)
myfunc()
myfunc("Testing from script4")
The error I am getting:
(base) C:UsersashishDesktopcode_202101282>python script4.py
Traceback (most recent call last):
File "script4.py", line 5, in <module>
code_obj = marshal.load(s)
ValueError: bad marshal data (unknown type code)
Please let me know if am doing something wrong and how to fix this.
question from:
https://stackoverflow.com/questions/65933705/facing-issue-with-loading-a-pyc-file-from-a-separate-script 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…