Python ord() Function (Code Examples)
What does the ord() function do? The built-in ord() function in Python converts any Unicode character into a number. It only takes one parameter which must be a single Unicode character, any more than one character produces an error. An example of the type of error you will get when sending more than 1 Unicode character is demonstrated here: 1 2 3 4 5 6 >>> ord('A') 65 >>> ord('ABC') Traceback (most recent call last): File "<input>", line 1, in <module> TypeError: ord() expected a character, but string of length 3 found Notice how Python informs us of what is expected – a character, but a string was passed in of length 3. ...