Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ord() and Unicode Table don't give the same number

Tags:

python

According to the Python documentation, ord() gives the corresponding number in Unicode. When I entered

ord('A')

I got the number 65. However, when I checked the Unicode number for 'A' in the site called Unicode Table (http://unicode-table.com/en), it says the number is 41.

Why is that happening? What is the correct reference guide to Unicode?

like image 351
user1691278 Avatar asked Jan 13 '23 03:01

user1691278


1 Answers

"41" is in hexadecimal.

>>> ord("A")
65
>>> hex(ord("A"))
'0x41'
>>> int("41",base=16)
65

Note that along the top of the page you linked, you see 0123456789ABCDEF, which is giving you the last digit.

like image 137
DSM Avatar answered Jan 19 '23 20:01

DSM