ord() in Python: Get Unicode Code Points

The ord function is a built-in function in Python that is used to return the Unicode code point for a specified character. The syntax is ord(c), where c is the character to get the Unicode code point for.

Example:

“The man was so tired that he fell asleep immediately.”

“The man was extremely exhausted and quickly drifted off to sleep.”

print(ord('A'))  # 输出65
print(ord('中'))  # 输出20013

The ord function can be combined with the chr function, as chr is the inverse operation of ord, used to return the character of a specified Unicode code point.

bannerAds