In this article, we will learn about Unicodedata – Unicode Database in Python 3.x. Or earlier.
Unicode Character Database modules provide all the features of Unicode to the character. The module uses identical names and symbols as mentioned in the module.
Now let’s look at some of the functions available in the module.
Lookup function
This function allows us to get the symbol for the corresponding name passed in the input.
Example
import unicodedata print (unicodedata.lookup('HYPHEN')) print (unicodedata.lookup('HIGH VOLTAGE SIGN') ) print (unicodedata.lookup('NO ENTRY') )
Output
- ⚡
Name function
This allows us to fetch the name of the corresponding symbol passed in the input.
Example
import unicodedata print (unicodedata.name(u'&')) print (unicodedata.name(u'@') ) print (unicodedata.name(u'`') )
Output
AMPERSAND COMMERCIAL AT GRAVE ACCENT
Category function
This allows us to detect the category of the symbol/letter/integer passed as input.
Example
import unicodedata print (unicodedata.category(u'&')) print (unicodedata.category(u'1') ) print (unicodedata.category(u'a') )
Output
Po Nd Ll
Conclusion
IN this article, we will learn about Unicode character database and some of the associated functions.