程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

How to batch convert PyC to py in Python Decompilation

編輯:Python

stay Python How to batch decompile pyc turn py

This article will explain in detail about Python How to batch decompile pyc turn py, Xiaobian thinks it's very practical , So share it for your reference , I hope you can gain something after reading this article .

What is? pyc file

pyc It's a binary file , By py The file is compiled , Generated files , It's a kind of byte code,py File becomes pyc After the document , The loading speed has increased , and pyc It's a cross platform bytecode , By python The virtual machine to execute , This is similar to JAVA perhaps .NET The concept of virtual machine .

Use uncompyle6 Can be pyc The file is converted to py file , therefore , You can also call CMD Carry out batch operation , The code is as follows :

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

About “ stay Python How to batch decompile pyc turn py” This article is shared here , I hope the above contents can be of some help to you , So that you can learn more , If you think the article is good , Please share it for more people to see .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved