Ord() and chr()
The ord() function in Python is used to get the Unicode code point of a specified character. It takes a single character as an argument and returns an integer representing its Unicode code point.
Here's a simple example:
char = 'A'
unicode_code_point = ord(char)
print(f"The Unicode code point of '{char}' is {unicode_code_point}")`
The Unicode code point of 'A' is 65
The ord() function is often used in conjunction with the chr() function, which does the opposite – it returns a string representing a character whose Unicode code point is the integer.
code_point = 65
character = chr(code_point)
print(f"The character with Unicode code point {code_point} is '{character}'")
This would output:
The character with Unicode code point 65 is 'A'
Keep in mind that Unicode is a standard that assigns a unique number to every character, regardless of the platform, program, or language. This allows for consistent representation of characters across different systems and applications.