Python中的ord和chr之类的方法 [英] Methods like ord and chr from Python

查看:71
本文介绍了Python中的ord和chr之类的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您知道在Java中与Python中的 ord chr 具有相同功能的任何函数。



Python文档。





我已经手动操作过,但似乎遇到了很多错误。这需要与 Strings 一起使用,而不仅仅是 char 。想通了,我会看看是否有功能可以预先构建。



谢谢

解决方案

您可以投射:

  c =(char)n; 

n =(int)c;


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

Python docs on them.

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

解决方案

You can cast:

c = (char) n;

n = (int) c;

这篇关于Python中的ord和chr之类的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆