Methods like ord and chr from Python

南楼画角 提交于 2019-12-10 12:45:50

问题


Do you know any functions that would preform the same as ord and chr from Python in Java.

Python docs on them.

  • 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.

Thanks


回答1:


You can cast:

c = (char) n;

n = (int) c;


来源:https://stackoverflow.com/questions/20250048/methods-like-ord-and-chr-from-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!