對python源碼進行編譯,加密python腳本


對python源碼進行編譯
1.生成.pyc文件
import py_compile
py_compile.compile('hello.py')
2.優化源碼文件
python -O -m py_compile 1.py
生成.pyo文件
 
例子:
 1 [root@lvs-master tool]# python3
 2 Python 3.5.6 (default, May  3 2019, 01:52:28) 
 3 [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
 4 Type "help", "copyright", "credits" or "license" for more information.
 5 >>> import py_compile
 6 >>> py_compile.compile('test_conn_linux.py')
 7 '__pycache__/test_conn_linux.cpython-35.pyc'
 8 >>> 
 9 >>> exit
10 Use exit() or Ctrl-D (i.e. EOF) to exit
11 
12 #執行部分
13 [root@lvs-master __pycache__]# python3 test_conn_linux.cpython-35.pyc
14   序號:0       選擇對象:172.16.132.4
15   序號:1       選擇對象:192.168.1.111
16   序號:2       選擇對象:47.106.169.222
17   序號:3       選擇對象:172.16.132.3
18 請輸入序號(Q|q退出)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM