如何从 .pyo 文件恢复源 python 代码 (.py)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2438578/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to recovery source python code (.py) from .pyo file?
提问by celka
I need to convert a compiled python code (.pyo) to its source . I look in depython.net, but there is a problem. A warning;
我需要将编译的 python 代码 (.pyo) 转换为它的源代码。我在 depython.net 中查看,但有一个问题。一个警告;
"File version older than 2.4."
“文件版本早于 2.4。”
What should I do?
我该怎么办?
Thanks.
谢谢。
回答by iraj jelodari
try these:
试试这些:
uncompyle2converts Python byte-code back into equivalent Python source code. It accepts byte-code from Python version 2.5 to 2.7. Additionally, it will only run on Python 2.7.
uncompyle2将 Python 字节码转换回等效的 Python 源代码。它接受从 Python 2.5 到 2.7 的字节码。此外,它只能在 Python 2.7 上运行。
uncompyle6translates Python bytecode back into equivalent Python source code. It accepts bytecodes from Python version 1.5
to 3.7
or so including Pypy-generated bytecode. The code requires Python 2.4 or later and has been tested on Python running versions 2.4, 2.5, 2.6, 2.7, 3.2, 3.3, 3.4, 3.5 and 3.6
.
uncompyle6将 Python 字节码转换回等效的 Python 源代码。它接受从 Python 版本1.5
到3.7
包含 Pypy 生成的字节码的字节码。该代码需要 Python 2.4 或更高版本,并且已经在 Python 运行版本上进行了测试2.4, 2.5, 2.6, 2.7, 3.2, 3.3, 3.4, 3.5 and 3.6
。
回答by Pratik Deoghare
Try decompyle.
尝试反编译。
This has become a commercial service.
To experiment with it you can use Debian Packages.
这已成为一种商业服务。
要试验它,您可以使用Debian Packages。
I would have loved to try it but I am on a windows machine. I will try it as soon as I get a chance.
我很想尝试一下,但我在 Windows 机器上。我一有机会就试试。