json不认numpy的array
import numpy as np
import json
a=np.asarray([1,2])
result={'name':'test','num':a}
json.dump(result)
TypeError: Object of type ‘ndarray’ is not JSON serializable
解决方案:
result={'name':'text','num':a.tolist()}
json不认numpy的array
import numpy as np
import json
a=np.asarray([1,2])
result={'name':'test','num':a}
json.dump(result)
TypeError: Object of type ‘ndarray’ is not JSON serializable
解决方案:
result={'name':'text','num':a.tolist()}