Python converts Unicode in list to Chinese display __python

Source: Internet
Author: User

have such a list:

List = [{' channel_id ': -3, ' name ': U ' \u7ea2\u5fc3\u5146\u8d6b '}, {u ' seq_id ': 0, U ' name_en ': U ' Personal Radio ', U ' channel_ Id ': 0, U ' abbr_en ': U ' my ', U ' name ': U ' \u79c1\u4eba\u5146\u8d6b '}]



where the name value is Chinese and how to speak it is displayed in Chinese.

s = str (self.channel_list). Replace (' u\ ', ' \ ')
print S.decode ("Unicode-escape")



Successful display:

[{' channel_id ': -3, ' name ': ' Red Hearts '}, {' seq_id ': 0, ' name_en ': ' Personal Radio ', ' channel_id ': 0, ' abbr_en ': ' My ', ' name ': ' Private MHz '},]



But at this point the type is Unicode

>>> type (s)
<type ' Unicode ' >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.