Object of type 'ndarray' is not JSON serializable

Object of type 'ndarray' is not JSON serializable

import numpy as np
import json


arr=np.asarray([345,45])
result={'name':'test','num':ar}


json.dump(result)

解决方法:

result={'name':'text','num':ar.tolist()}

json不认numpy的array

posted on 2019-02-28 17:28  疯狂的小萝卜头  阅读(3821)  评论(0编辑  收藏  举报