How do you use the ord() function in Python?

The ord() function is used to return the Unicode code value of a character.

The method to use is: ord(ch), where ch is a character.

The following is an example:

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

Note: The ord() function can only accept one character as a parameter, and will error if a string is passed in.

bannerAds