如何从 .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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-04 00:38:42  来源:igfitidea点击:

How to recovery source python code (.py) from .pyo file?

pythonwxpythonextension-methodsdecompiling

提问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.5to 3.7or 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.53.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 机器上。我一有机会就试试。

回答by Joschua

there is Decompile, the reputed cheap (but you can test it online) depythonand the UnPycproject (is only for 2.5 <=). Also hereis another SO-Question related to this.

Decompile,著名的廉价(但您可以在线测试)depythonUnPyc项目(仅适用于 2.5 <=)。同时这里是与此相关的另一个SO-问题。

I hope it helps.

我希望它有帮助。