在Python反编译中批量pyc转 py
使用uncompyle6可以将pyc文件转换为py文件,因此,也可以调用CMD进行批量操作,代码如下:
import os import sys def walk_dir(dir,topdown=True): words=[] words=['asyncio.','attr.','bs4.','chardet.','Crypto.','chardet.','concurrent.','ctypes.','dateutil.','distutils.','email.','et_xmlfile.','fiona.','geographiclib.','geojson.','geopandas.','geopy.','html.','http.','importlib.','jinja2.','multiprocessing.','numpy.','openpyxl.','pandas.','pkg_resources.','pyecharts.','pyproj.','pytz.','requests.','setuptools.','shapely.','simplejson.','soupsieve.','sqlalchemy.','unittest.','urllib3.','xlsxwriter.','xml.','xlrd.'] for root, dirs, files in os.walk(dir, topdown): for name in files: if name.endswith('.pyc'): part_name = name[0:-4] part_file_name = os.path.join(root, part_name).replace("\\","/") isconvert=True for w in words: if (name.startswith(w)): isconvert=False break if isconvert: os.system('uncompyle6 -o "%s.py" "%s.pyc"'%(part_file_name,part_file_name)) print(part_file_name) walk_dir(os.getcwd())
作者:我也是个傻瓜
出处:http://www.cnblogs.com/liweis/
签名:成熟是一种明亮而不刺眼的光辉。