json.loads(json_ Data)
error
Modify to json.loads (JSON_ Data. Decode ())
is OK
Some modifications will bring new error reports
Add code () directly to solve the problem
Description
The python decode() method decodes the string in the encoding format specified by encoding. The default encoding is string encoding
Grammar
Code() method syntax:
str.decode(encoding='UTF-8',errors='strict')
Parameters
encoding — encoding to be used, such as “UTF-8”
errors — set different error handling schemes. The default is’ strict ‘, which means a Unicode error caused by an encoding error. Other possible values are ‘ignore’, ‘replace’, ‘xmlchar replace’, ‘backslashreplace’ and through codecs. Register_ Any value registered by error()
Return value
This method returns the decoded string
Examples
The following example shows an example of the decode() method:
Instance (Python 3.0 +)
#!/ usr/bin/python str = “this is string example….wow!!!”; str = str.encode(‘base64′,’strict’); print “Encoded String: ” + str; print “Decoded String: ” + str.decode(‘base64′,’strict’)
The output results of the above examples are as follows:
Encoded String: dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE= Decoded String: this is string example....wow!!!
Similar Posts:
- Python: How to Solve raise JSONDecodeError(“Expecting value”, s, err.value) from None json.decoder…
- [Solved] TypeError: string indices must be integers, not str
- UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-1:
- [Solved] Python Error: UnicodeDecodeError: ‘gb2312’ codec can’t decode byte 0xa4 in position… : illegal multibyte sequence
- [Solved] Typeerror: incorrect padding occurred in python3 Base64 decoding
- Python JSON error json.decoder.jsondecodeerror Chinese
- Error reporting and resolution of Python 3 using binascii method
- [Solved] JSON check syntax error: json.decoder.JSONDecodeError: Invalid control character at: line 1 column
- [Solved] json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- attributeerror: ‘str’ object has no attribute ‘decode’