如何将非ascii范围字符串的unicode表示转换为python字符串?你知道吗
> str = '<some-arabic-content>'
> decoded_str = str.decode('utf-8')
> decoded_str
u'\u0623\u0646\u0633\u0646\u0629'
> str(decoded_str)
<WILL-THROW-AN-ERROR-OFC> since ascii cannot encode the unicode string
如何将this表示('\u0623\u0646\u0633\u0646\u0629')作为python字符串获取?就像下面的那个。你知道吗
> str_rep = '\u0623\u0646\u0633\u0646\u0629'
我想从decoded_str
登陆str_rep
。我该怎么做呢?你知道吗
decoded_str.encode("unicode-escape")
产生所需的输出。你知道吗你有没有试着打印你的解码变量??你知道吗
相关问题 更多 >
编程相关推荐