代码点读机 / Python / ord

ord Python · 内置函数

把字符转成对应的 Unicode 编码数字,和 chr 互为反操作。

怎么用

ord(字符)

小例子

print(ord('A'))
print(ord('中'))

运行结果

65
20013

官方文档:https://docs.python.org/zh-cn/3/library/functions.html#ord

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Python全部词条