首页 > Python函数 > 正文

python函数每日一讲 - chr(i)

chr(i)

中文说明:

返回整数i对应的ASCII字符。与ord()作用相反。

参数x:取值范围[0, 255]之间的正数。

版本:该函数在python2和python3各个版本中都可用。不存在兼容性问题。


英文说明:

Return a string of one character whose ASCII code is the integer i. For example, chr(97) returns the string 'a'. This is the inverse of ord(). The argument must be in the range [0..255], inclusive; ValueError will be raised if i is outside that range. See also unichr().


代码实例

>>> chr(97)
'a'
>>> chr(98)
'b'
>>> ord('a')
97
>>> ord('b')
98

ps:呵呵,这个函数和php里面的用法是一样的哦


上一篇:python函数每日一讲 - callable(object)
下一篇:python函数每日一讲 - classmethod()

PythonTab微信公众号:

Python技术交流互助群 ( 请勿加多个群 ):

群1: 87464755

群2: 333646237

群3: 318130924

群4: 385100854