Python:Ascii字符-十进制表示形式转换 [英] Python:Ascii character<->decimal representation conversion
本文介绍了Python:Ascii字符-十进制表示形式转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要能够将ascii字符转换为等效的十进制数,反之亦然.
我该怎么办?
解决方案
num=ord(char)
char=chr(num)
例如,
>>> ord('a')
97
>>> chr(98)
'b'
您可以在此处中阅读有关Python内置函数的更多信息.. >
Hi I need to be able to convert a ascii character into its decimal equivalent and vice-versa.
How can I do that?
解决方案
num=ord(char)
char=chr(num)
For example,
>>> ord('a')
97
>>> chr(98)
'b'
You can read more about the built-in functions in Python here.
这篇关于Python:Ascii字符-十进制表示形式转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文