1.生成.pyc文件
python -m compileall xxx # xxx:可以是目录,也可是单个文件
2.删除目录下所有.pyc文件
find xxx -name "*.pyc" | xargs rm -rf # xxx: 是目录,例如 /www/web
3.打包例子
# 先删除原有的.pyc文件 find broject -name '*.pyc' | xargs rm -f # 生成新的.pyc文件 python -m compileall broject # 打包成.zip N=`date +%y%m%d%H%M` tar -zcvf test${N}.tar.gz broject/ \ --exclude="broject/gitup" \ --exclude="broject/test" \ --exclude="broject/public/thumb" \ --exclude="broject/public/cvtest" \ --exclude="broject/public/WebDeploy" \ --exclude="broject/var/*.pid" \ --exclude="broject/var/*.log" \ --exclude="broject/var/upload_temp" \ --exclude="broject/*.py" \ --exclude="broject/**/*.py" \ --exclude="broject/.git" --exclude=".*"