I have written python code and saved as program.py file.Now When i open "program.py" file it should be unreadable format.
Can anyone suggest me how to fix this issue.
I have written python code and saved as program.py file.Now When i open "program.py" file it should be unreadable format.
Can anyone suggest me how to fix this issue.
You can creat pyc file with compileall:
Put your python files in a folder and run the command in this folder:(Source)
python -m compileall .
This command will produce a pyc file in __pycache__ folder. You can use this file like other python files:(Source)
python myfile.pyc
pyc files contain the bytecode to speed up the process for the next run. However, it is not readable in general.One way to do that is by compiling the source code using the py_compile module:
python -m py_compile my-py-source.py
The compiled source code will be in _pycache/my-py-source.pyc (relative to your current directory). And the code will still run normally when you run python my-py-source.pyc.