python chr函数 ord_python函数chr,ord

chr(i)

中文说明:

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

参数x:返回表示一个字符的ASCII/Unicode代码点整数。

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

英文说明:

Return the string representing a character whose Unicode code point is the integer i. For example, chr(97) returns the string 'a'. This is the inverse of ord(). The valid range for the argument is from 0 through 1,114,111 (0x10FFFF in base 16). ValueError will be raised if i is outside that range.

ord(str)

中文说明:

返回字符串str对应ASCII/Unicode整数值。与chr()作用相反

参数x:返回单字符在ASCII/Unicode中对应的整数

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

英文说明:

Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. For example, ord('a') returns the integer 97 and ord('\u2020') returns 8224. This is the inverse of chr().

代码实例:

>>> chr(97)'a'

>>> chr(98)'b'

>>> ord('a')97

>>> ord('b')98

你可能感兴趣的:(python,chr函数,ord)