all Python 3unicodedataterm
unicodedata
module
Access to the Unicode Character Database: character names and categories, numeric values, string normalization.
Syntax
import unicodedata
Use unicodedata when strings that look the same compare as different: "é" can be one character or a letter plus a separate accent, and normalize("NFC", s) brings them to one form. The module also tells you what a character is — name() and category() — and finds a character by name with lookup(). It is not needed for plain case conversion: for caseless comparison there is str.casefold().
Examples
import unicodedata
print(unicodedata.name("é")) # → LATIN SMALL LETTER E WITH ACUTE
s = "e\u0301"
print(len(s), len(unicodedata.normalize("NFC", s))) # → 2 1
print(unicodedata.category("7")) # → Nd
See also
Open in the full glossarydocs.python.orgReport an inaccuracy