V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
billgreen1
V2EX  ›  Python

如何通过 co_code 反编译成 python source code?

  •  
  •   billgreen1 · 2016-07-03 13:50:45 +08:00 · 3144 次点击
    这是一个创建于 2854 天前的主题,其中的信息可能已经有所发展或是发生改变。
    背景:
    网上 python 平台,在线环境,一直想知道某个函数是怎么实现的。
    平台限制了 python package 的使用,所以 dis , inspect ,等都是不能用的。

    但是可以通过 func.__code__.co_code 获取编译了的 byte string.

    想问下可以通过这个 byte string 反编译成 python 的 source code 嘛。
    1 条回复    2016-07-03 14:20:22 +08:00
    shyling
        1
    shyling  
       2016-07-03 14:20:22 +08:00 via iPad
    在其他环境里 dis.dis(func.__code__.co_code)😉
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2768 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 05:37 · PVG 13:37 · LAX 22:37 · JFK 01:37
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.