Python3 ord() 函數

Python3 內置函數 Python3 內置函數


描述

ord() 函數是 chr() 函數(對於 8 位的 ASCII 字串)的配對函數,它以一個字串(Unicode 字元)作為參數,返回對應的 ASCII 數值,或者 Unicode 數值。

語法

以下是 ord() 方法的語法:

ord(c)

參數

  • c -- 字元。

返回值

返回值是對應的十進位整數。


實例

以下展示了使用 ord() 方法的實例:

>>>ord('a') 97 >>> ord('') 8364 >>>

Python3 內置函數 Python3 內置函數