如何在 Python 中将字符转换为整数,反之亦然? [英] How can I convert a character to a integer in Python, and viceversa?
本文介绍了如何在 Python 中将字符转换为整数,反之亦然?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定一个字符,我想得到它的 ASCII
值.
I want to get, given a character, its ASCII
value.
例如对于字符a
,我想得到97
,反之亦然.
For example, for the character a
, I want to get 97
, and vice versa.
推荐答案
>>> chr(97)
'a'
>>> ord('a')
97
这篇关于如何在 Python 中将字符转换为整数,反之亦然?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文