小编use*_*968的帖子

将 numpy 数组列表转换为 json 以从 Flask api 返回

我在 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

python serialization json numpy flask-restful

7
推荐指数
1
解决办法
2786
查看次数

在c ++中将数字char转换为int(与char相同)

我有一个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)

给出错误的答案.这样做的功能或正确方法是什么?

c++

1
推荐指数
1
解决办法
181
查看次数

标签 统计

c++ ×1

flask-restful ×1

json ×1

numpy ×1

python ×1

serialization ×1