The ucnhash Module
(Implementation, 2.0 only) The ucnhash
module is an implementation module,
which provides a name to character code mapping for Unicode string
literals. If this module is present, you can use \N{}
escapes to
map Unicode character names to codes, as shown in Example 8-4.
Example 8-4. Using the ucnhash Module
File: ucnhash-example-1.py # Python imports this module automatically, when it sees # the first \N{} escape # import ucnhash print repr(u"\N{FROWN}") print repr(u"\N{SMILE}") print repr(u"\N{SKULL AND CROSSBONES}")u'\u2322'
u'\u2323'
u'\u2620'
Get Python Standard Library now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.