首页 > 代码库 > 编译pyhon程序(pyc,pyo)

编译pyhon程序(pyc,pyo)

.命令交互模式

[release@ZABBIXSERVER MonSMS]$ python -m py_compile  MonSMS.py
总用量 69996
-rwxr-xr-x 1 release release     7594 9月   8 2016 MonSMS.py
-rw-rw-r-- 1 release release 71597401 5月  15 11:15 MonSMS.log
[release@ZABBIXSERVER MonSMS]$ python -m py_compile  MonSMS.py
[release@ZABBIXSERVER MonSMS]$ ls -lrt
总用量 70004
-rwxr-xr-x 1 release release     7594 9月   8 2016 MonSMS.py
-rw-rw-r-- 1 release release 71597401 5月  15 11:15 MonSMS.log
-rw-rw-r-- 1 release release     6200 5月  15 11:21 MonSMS.pyc
[release@ZABBIXSERVER MonSMS]$  python -O -m py_compile  MonSMS.py
[release@ZABBIXSERVER MonSMS]$ ls -lrt
总用量 70012
-rwxr-xr-x 1 release release     7594 9月   8 2016 MonSMS.py
-rw-rw-r-- 1 release release 71597401 5月  15 11:15 MonSMS.log
-rw-rw-r-- 1 release release     6200 5月  15 11:21 MonSMS.pyc
-rw-rw-r-- 1 release release     6200 5月  15 11:22 MonSMS.pyo

.程序编译

import py_compile
py_compile.compile(r/TOOLS/MonSMS/MonSMS.py)
[release@ZABBIXSERVER MonSMS]$ ls -lrt
总用量 70008
-rwxr-xr-x 1 release release     7594 9月   8 2016 MonSMS.py
-rw-rw-r-- 1 release release 71597401 5月  15 11:15 MonSMS.log
-rw-rw-r-- 1 release release     6200 5月  15 11:22 MonSMS.pyo
-rw-rw-r-- 1 release release       65 5月  15 11:26 python_compile.py
[release@ZABBIXSERVER MonSMS]$ python python_compile.py 
[release@ZABBIXSERVER MonSMS]$ ls -lrt
总用量 70016
-rwxr-xr-x 1 release release     7594 9月   8 2016 MonSMS.py
-rw-rw-r-- 1 release release 71597401 5月  15 11:15 MonSMS.log
-rw-rw-r-- 1 release release     6200 5月  15 11:22 MonSMS.pyo
-rw-rw-r-- 1 release release       65 5月  15 11:26 python_compile.py
-rw-rw-r-- 1 release release     6214 5月  15 11:28 MonSMS.pyc

 

编译pyhon程序(pyc,pyo)