我在 python 中有一个这样的字典:
mydic = {
'x1': list_of_numpy_array,
'x2': a numpy_array,
'x3': a list_of_numpy_array,
'x4': a list_of_numpy_array
}
Run Code Online (Sandbox Code Playgroud)
我想将此字典发送给flask-api调用此 api 的客户端。当我使用此代码时:
class GetRepresentationResource(Resource):
url = 'representation'
def get(self):
# previous lines of my code which generates mydic
return {
'data': mydict,
'err': ''
}
Run Code Online (Sandbox Code Playgroud)
我得到错误: Is not serializeable
我有一个char数组,所有数组都是数字,但Char类型意味着:
myArray = ['5','6','8','9','10',....]
Run Code Online (Sandbox Code Playgroud)
例如,我想添加其中两个.我必须将它们转换为整数,然后将它们添加到一起,但使用:
(int)myArray[1]+(int)myArray[2]
Run Code Online (Sandbox Code Playgroud)
给出错误的答案.这样做的功能或正确方法是什么?