登录
上传中....
如何在 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() 和 ord():
>>> chr(97) 'a' >>> ord('a') 97