如何使用 Python 查找字符的 ASCII 值?

pythonprogramming

python 中的 ord 函数给出字符的序数值(ASCII)。您可以使用此函数查找 ascii 代码,如下所示

示例

s = "Hello"
for c in s:
   print(ord(c))

输出

这将给出输出

72
101
108
108
111

相关文章