如何有效地将 Java 代码转换为 python?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38203533/
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-08-19 20:30:37  来源:igfitidea点击:

how can I translate efficiently a Java code to python?

python

提问by nik

I would be greatfull if you could tell me how one can translate a code from Java to python.
Should one do it manually ? is there any tool to convert it automatically?

如果您能告诉我如何将代码从 Java 转换为 Python,我会非常高兴。
应该手动做吗?有什么工具可以自动转换吗?

回答by syntonym

If you want to translate java code to python you have to translate it manually. Automatic conversion generally does not have the appropriate quality. It looks like there are some tools out e.g. java2pythonbut the author states

如果你想将 java 代码翻译成 python,你必须手动翻译它。自动转换一般没有合适的质量。看起来有一些工具,例如java2python但作者指出

The generated Python code is not guaranteed to run, nor is guaranteed to be syntactically valid Python.

生成的 Python 代码不保证可以运行,也不保证在语法上是有效的 Python。

Converting a library to another programming language is never an easy task.

将库转换为另一种编程语言从来都不是一件容易的事。

If you simply want to use a java library in a application that you want to write in python you could give jythona try.

如果你只是想在你想用 python 编写的应用程序中使用 java 库,你可以试试jython