就是这样:
In [1]: '中文'.decode('utf8')
Out[1]: u'\u4e2d\u6587'
In [2]: u'\u4e2d\u6587'.encode('utf8')
Out[2]: '\xe4\xb8\xad\xe6\x96\x87'
In [3]: unicode('\u4e2d\u6587')
Out[3]: u'\\u4e2d\\u6587'
好了,问题是,如何在python下,接收类似'\u4e2d\u6587'的字符串,然后输出'中文'呢?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
print u'\u4e2d\u6587'.encode('utf8')