Next / Previous / Contents / TCC Help System / NM Tech homepage

20.31. ord(): Find the numeric code for a character

Given a string s containing a single character, ord(s) returns that character's numeric code. Compare Section 20.7, “chr(): Get the character with a given code”.

>>> ord('A')
65
>>> ord('\x00')
0
>>> ord(u'\u262e')
9774
>>> hex(9774)
'0x262e'