在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())

  

posted @ 2022-02-15 07:31  我也是个傻瓜  阅读(1050)  评论(0编辑  收藏  举报