How to find out number/name of unicode character in Python? How to find out number/name of unicode character in Python? python-3.x python-3.x

How to find out number/name of unicode character in Python?


You may find the unicodedata module handy:

>>> s = "\N{BLACK SPADE SUIT}">>> s'♠'>>> import unicodedata>>> unicodedata.name(s)'BLACK SPADE SUIT'>>> ord(s)9824>>> hex(ord(s))'0x2660'