[Python]json Object Conversion Error expected string or buffer Python

Source: Internet
Author: User

Problem

There is a problem with the JSON transformation in Python today:

Error display: expected string or buffer

The JSON content is as follows:

{u ' err_no ': 0, U ' corpus_no ': U ' 6594675362334657196 ', U ' err_msg ': U ' success. ', U ' result ': [u ' \uff0c '], u ' sn ': U ' 829195370711535442509 '}

"Analytical Solution"

After debugging, it turns out that single quotation marks are used to denote the string "'" By default in Python, so when a string character value is used, Python converts the double quotation marks to single quotes.

The JSON does not support single quotes. You can use the following method to convert

Json_string=json.dumps (s)

Str=json.loads (json_string)

[Python]json Object Conversion Error expected string or buffer Python

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.