Mod() Function In Python

Overview:

  • Given the string representation of a Unicode character the function returns the corresponding numeric value. This numeric value is also called a code point.
  • The function chr() does the opposite of mod() function. Given a code point it returns the string containing the unicode character.

Example:

# Example Python program that gets the codepoint
# for a given unicode character
char        = "ア"
codepoint   = ord(char)
print("The unicode chracter:%s"%char)
print("Corresponding codepoint:%d"%codepoint)
print("Codepoint as a hexadecimal number:%s"%hex(codepoint))

 

Output:

The unicode chracter:ア

Corresponding codepoint:12450

Codepoint as a hexadecimal number:0x30a2

 


Copyright 2020 © pythontic.com