Python3下不要版本号批量编译.pyc文件
2016-06-28 16:49
555 查看
code say:
相关阅读:
1、py_compile
2、compileall — Byte-compile Python libraries
3、PEP 3147 -- PYC Repository Directories
4、关于Python的编译
*** walker ***
#encoding=utf-8 #author: walker #date: 2016-06-28 #summary: 编译当前文件夹下所有.py文件 import os, sys, shutil import py_compile cur_dir_fullpath = os.path.dirname(os.path.abspath(__file__)) #清空目录 def ClearDir(dir): print('ClearDir ' + dir + '...') for entry in os.scandir(dir): if entry.name.startswith('.'): continue if entry.is_file(): os.remove(entry.path) #删除文件 else: shutil.rmtree(entry.path) #删除目录 #编译当前文件夹下所有.py文件 def WalkerCompile(): dstDir = os.path.join(cur_dir_fullpath, 'walker_compile') if os.path.exists(dstDir): #如果存在,清空 ClearDir(dstDir) else: #如果不存在,创建 os.mkdir(dstDir) for filename in os.listdir(cur_dir_fullpath): if not filename.endswith('.py'): continue srcFile = os.path.join(cur_dir_fullpath, filename) if srcFile == os.path.abspath(__file__): #自身 continue dstFile = os.path.join(dstDir, filename + 'c') print(srcFile + ' --> ' + dstFile) py_compile.compile(srcFile, cfile=dstFile) if __name__ == "__main__": WalkerCompile()
相关阅读:
1、py_compile
2、compileall — Byte-compile Python libraries
3、PEP 3147 -- PYC Repository Directories
4、关于Python的编译
*** walker ***
相关文章推荐
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- install and upgrade scrapy
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- Python中zip()函数用法举例
- Python中map()函数浅析
- Python将excel导入到mysql中
- Python在CAM软件Genesis2000中的应用
- 使用Shiboken为C++和Qt库创建Python绑定
- FREEBASIC 编译可被python调用的dll函数示例
- Python 七步捉虫法