Chr (), UNICHR () and Ord ()
The CHR () function returns a corresponding character by using an integer (that is, 0~255) within range (256) as a parameter. UNICHR () is just like it, except that the Unicode character is returned, and the parameter range of the UNICHR () added from Python 2.0 depends on how your Python is compiled. If it is configured to USC2 Unicode, then it is allowed to range (65536) or 0X0000-0XFFFF, if configured as UCS4, then this value should be range (1114112) or 0x000000-0x110000. If the supplied parameter is not within the allowable range, a ValueError exception is reported.
The Ord () function is the Chr () function (for 8-bit ASCII strings) or the UNICHR () function (for Unicode objects), which returns the corresponding ASCII value, or Unicode value, as a parameter with a character (a string of length 1). If the given Unicode character exceeds your Python definition range, a TypeError exception is thrown.
>>> Chr (65)
A
>>> Ord (' a ')
97
>>> UNICHR (12345)
U ' \u3039 '
>>> chr (12345)
Traceback (most recent):
File "<stdin>", line 1, in?
Chr (12345)
VALUEERROR:CHR () arg not in range (256)
>>> ord (U ' \ufffff ')
Traceback (most recent):
File "<stdin>", line 1, in?
Ord (U ' \ufffff ')
Typeerror:ord () expected a character, but string of length 2 found
>>> ord (U ' \u2345 ')
9029
The Ord function in Python