1. 程式人生 > >json.decoder.JSONDecodeError: Invalid control character at: line 1 column 3,python中str與json型別轉換報錯如何解

json.decoder.JSONDecodeError: Invalid control character at: line 1 column 3,python中str與json型別轉換報錯如何解

使用json轉:

json資料保密,再此不展示。

# 判斷型別
print(type(str_json))
json_dump = json.loads(str_json)

報錯如下:

json.decoder.JSONDecodeError: Invalid control character at: line 1 column 33652 (char 33651)

解決:

# use simplejson.loads() make str to dictionary type
json_dump = simplejson.loads(str_json, strict=False)

完美解決!