Java Python 中的 ord 和 chr 等方法

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

Methods like ord and chr from Python

javapythonconverter

提问by Kyle93

Do you know any functions that would preform the same as ordand chrfrom Python in Java.

您是否知道在 Java 中执行ordchrPython相同的任何函数。

Python docs on them.

关于它们的 Python 文档。

I've experienced manually but seem to get so many errors. This would need to work with Stringsnot just char. Figured I would see if there was a function to do it pre-built.

我已经手动体验过,但似乎遇到了很多错误。这将需要工作,Strings而不仅仅是char。想我会看看是否有一个功能可以预先构建。

Thanks

谢谢

采纳答案by Simeon Visser

You can cast:

你可以投射:

c = (char) n;

n = (int) c;