This article mainly introduces the use of Compileall module in Pyhthon to compile source files for PYc files, the need for friends can refer to the following
Sometimes we need to compile all of the Python source files of the project. Py into a. pyc file, leaving only the. pyc file and releasing it to others (although it can be recompiled, it is a protection).
At this point, you can use the Compileall library to do this work, which can recursively compile all the. py files under a folder into a. pyc file.
For example, I have a Django project under the Test folder to
The code is as follows:
E:>python-c "Import Compileall; import re; Compileall.compile_dir (' Test ', Rx=re.compile (R ' [/][.] SVN '), force=true) "
For more use and parameters please refer to
Then you want to delete the. py file retention. pyc file.
You can use the Find command directly under Linux, you can use DOS commands in Windows, and you can write a Python script to delete these files