python

导航

ord在python是什么意思?怎么使用?

来源 :中华考试网 2020-12-26

  Help on built-in function ord in module builtins:

  ord(...) #这是一个函bai数du

  ord(c) -> integer #接受一个参数,zhi返dao回zhuan值是int,整数

  Return the integer ordinal of a one-character string. #参数是长度为shu1的字符,返回它对应的整数

  示例:

  >>> s = ord('a')

  >>> s

  97

  明白了吧,就是返回单字符在ASCII中对应的整数

分享到

您可能感兴趣的文章