qiuyouzhi 发表于 2020-3-20 09:24:01

Python ord() 函数

本帖最后由 一个账号 于 2020-3-20 09:33 编辑

Python ord() 函数

语法:

ord(c)

参数:



参数描述

c字符



返回值:

返回值是字符的ASCII码(十进制整数)

例子:

>>> ord('s')
115
>>> ord('a')
97
>>> ord('A')
65
>>> ord('1')
49
>>> ord('qiuyouzhi')
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
    ord('qiuyouzhi')
TypeError: ord() expected a character, but string of length 9 found
>>> # 不能是多个字符

一个账号 发表于 2020-3-20 09:27:51



参数描述

NoneNone

墨羽岚 发表于 2020-3-20 09:32:29

一个账号 发表于 2020-3-20 09:27


你的代码复制是不是出问题了{:10_245:}
页: [1]
查看完整版本: Python ord() 函数