How to convert a string into a pyc file without using a py file?

740 views Asked by At

I have a string print("hello"). I want to directly store this as a .pyc file and execute it later. How can I do this?

1

There are 1 answers

4
Vincent On BEST ANSWER

Take a look at the py_compile.compile and its source code to see how it is done.