TypeError: Object of type ‘ndarray‘ is not JSON serializable
保存json文件:
import json info = {"key_1": "value_1", "key_2": "value_2", "key_3": {"key_4": "value_4", "key_5": "value_5"}} with open("a.json", "w") as f: f.write(json.dumps(info, ensure_ascii=False, indent=4, separators=(',', ':')))
读取json文件:
with open('./a.json', 'r', encoding = 'utf8') as fp: json_data = json.load(fp)