def ucn_to_unicode(ucn):
    """
    Convert a Unicode Universal Character Number (e.g. "U+4E00" or "4E00") to
    Python unicode (u'\\u4e00')
    """
    if isinstance(ucn, string_types):
        ucn = ucn.strip("U+")
        if len(ucn) > int(4):
            char = b'\U' + format(int(ucn, 16), '08x').encode('latin1')
            char = char.decode('unicode_escape')
        else:
            char = unichr(int(ucn, 16))
    else:
        char = unichr(ucn)

    assert isinstance(char, text_type)

    return char
def ucn_to_unicode ( ucn ) : if isinstance ( ucn , string_types ) : ucn = ucn . strip ( "U+" ) if len ( ucn ) > int ( 4 ) : char = b'\U' + format ( int ( ucn , 16 ) , '08x' ) . encode ( 'latin1' ) char = char . decode ( 'unicode_escape' ) else : char = unichr ( int ( ucn , 16 ) ) else : char = unichr ( ucn ) assert isinstance ( char , text_type ) return char
Convert a Unicode Universal Character Number (e.g. "U+4E00" or "4E00") to
    Python unicode (u'\\u4e00')