Json.dumps python error: ' UTF8 ' codec can ' t decode byte 0xe

Source: Internet
Author: User
Tags json

Json.dumps python error: ' UTF8 ' codec can ' t decode byte 0xe1 in position 5 ...

Because of the working relationship, you want to use Python to generate JSON data as a text file, but you encounter the above coding problem:

Import JSON

Json.dumps (RST)

ERROR: "Unicodedecodeerror: ' UTF8 ' codec can ' t decode byte 0xe1 in position 5:unexpected end of data"

See the error prompts we can basically determine that this is a coding problem, OK, then we'll go to Google

Finally let me find the solution:

All we need to do is Unicode the string, ignoring the error, and the code is as follows:

Unicode (RST, errors= ' ignore ')

Note, however, that the RST here must be a string, so I don't have to tell you what to do next.

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/

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.