English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
ord()函数返回一个表示Unicode字符的整数。
ord()的语法为:
ord(ch)
ord()函数采用单个参数:
ch -Unicode字符
ord()函数返回一个表示Unicode字符的整数。
print(ord('5')) # 53 print(ord('A')) # 65 print(ord('$')) # 36
输出结果
53 65 36
顺便说一句,ord()函数与Python chr()函数的作用相反