Object of type 'ndarray' is not JSON serializabl
import numpy as npimport jsonarr = np.asarray([345, 45])result = {'name': 'test', 'num': arr}json.dump(result)报错:TypeError: Object of type ndarray is not JSON serializable解决办法:result={'na...
·
import numpy as np
import json
arr = np.asarray([345, 45])
result = {'name': 'test', 'num': arr}
json.dump(result)
报错:
TypeError: Object of type ndarray is not JSON serializable
解决办法:
result={'name':'text','num':arr.tolist()}更多推荐




所有评论(0)