Python3.6内置函数(48)——ord

英文文档 ord(c) Given a string representing one Unicod

英文文档

  • ord(c)

    Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. For example,ord('a')returns the integer97andord('€')(Euro sign) returns8364. This is the inverse ofchr().

    ord()

    ord(c)返回Unicode字符对应的整数。

    1、函数功能传入一个Unicode 字符,返回其对应的整数数值。

    >>> ord('a')

    97

    >>> ord('@')

    64

    2、其功能和chr函数刚好相反。

    >>> chr(97)

    'a'

    >>> chr(64)

    '@'

    小结

    希望通过上面的操作能帮助大家。如果你有什么好的意见,建议,或者有不同的看法,希望你留言和我进行交流、讨论。

打开APP阅读更多精彩内容