首页 > 代码库 > chr &ord

chr &ord

def chr(*args, **kwargs):    """ Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff. """
def ord(*args, **kwargs):     """ Return the Unicode code point for a one-character string. """

chr(i)

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

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

print(chr(97))   # 结果 a print(ord(‘a‘))  # 结果 97

  

chr &ord