chr &ord

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章

飘逸的python - ord和chr以及unichr

python的内置函数ord()chr()str()

chr()ord()函数

python中ord()函数和chr()函数用法

chr() ord()

Python二级考试基础知识(ord,chr函数详解)