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
Methods like ord and chr from Python
提问by Kyle93
Do you know any functions that would preform the same as ord
and chr
from Python in Java.
您是否知道在 Java 中执行ord
与chr
Python相同的任何函数。
Python docs on them.
关于它们的 Python 文档。
- http://docs.python.org/2/library/functions.html#ord
- http://docs.python.org/2/library/functions.html#chr
- http://docs.python.org/2/library/functions.html#ord
- http://docs.python.org/2/library/functions.html#chr
I've experienced manually but seem to get so many errors. This would need to work with Strings
not 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;