如你之前的json文件為:girl.json
解決方案:將該json文件從之前的UTF-8轉換為ANSI編碼。或者UTF-8無BOM格式編碼的。
然后json.loads就可以識別,並轉換為python對象了
實例:json文件
{
"employees": [
{ "firstName":"Bill" , "lastName":"Gates" },
{ "firstName":"George" , "lastName":"Bush" },
{ "firstName":"Thomas" , "lastName":"Carter" },
{"姓":"付","名":"航"}
]
}
python代碼:
#!usr/bin/env python
# -*- coding:utf-8 -*-
import json
f = open("girl.json",encoding='utf-8')
s = json.load(f)
print(s)
參考鏈接:https://www.crifan.com/fixed_problem_for_python_valueerror_no_json_object_could_be_decoded/
感謝
