Protobuf嵌套映射不可编辑

2024-09-29 23:25:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我想以python形式定义一个与此等效的参数:

request = {'my_param': {'nested_map': {'code':0,'description: 'blah'}}} 

下面是我的原型文件:

    message MyRequest {
        map<string,MyParam> my_param = 1;
    }
    
    message MyParam {
      map<string, NestedMap> nested_map = 1;
    }
    
    message NestedMap {
        int32 code = 1;
        string description = 2;
    }

现在我尝试定义我的请求

request = MyRequest(MyParam(NestedMap(code=0, description='blah')))

TypeError: Argument MyParam is not iterable

为什么会出现这个错误?如何正确定义这一点


Tags: mapmessagestring定义paramrequestmycode

热门问题