Object of type 'ndarray' is not JSON serializable
import numpy as np import json ar=np.asarray([345,45]) result={'asdf':'asdf','54':ar} with open("./hmm.json", 'w', encoding='utf-8') as json_file: json.dump(result,json_file,ensure_ascii=False)
解决方法:
result={'asdf':'asdf','54':ar.tolist()}
json不认numpy的array。