重新组装Python字节码为原始代码? [英] Reassembling Python bytecode to the original code?

查看:145
本文介绍了重新组装Python字节码为原始代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个愚蠢的问题,但是考虑到输出结果,例如。

This might be a silly question, but, given the output of, say..

>>> from dis import dis
>>> def myfunc(x):
...     print x ** 2
... 
>>> dis(myfunc)
  2           0 LOAD_FAST                0 (x)
              3 LOAD_CONST               1 (2)
              6 BINARY_POWER        
              7 PRINT_ITEM          
              8 PRINT_NEWLINE       
              9 LOAD_CONST               0 (None)
             12 RETURN_VALUE        

..或 .pyc 文件-是否可以将其重新组装成有效的Python源代码?也就是说,其中 reassemble(dis(myfunc))== def reassembled_function(x):\n print x ** 2;

..or a .pyc file - is it possible to reassembling this into a valid piece of Python source code? I.e where reassemble(dis(myfunc)) == "def reassembled_function(x):\n print x ** 2"

不是出于任何特定的实际原因,我只是想知道这是否可行或已尝试。。

Not for any particular practical reason, I'm just curious if this is possible, or has been attempted..

  • Free Python decompiler that is not an online service?

推荐答案

http://sourceforge.net/projects/decompyle/

这篇关于重新组装Python字节码为原始代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆