python 在运行时获取 protobuf 实例的包名称
Get package name for protobuf instance at runtime in python
如果我有一个 protobuf 实例,有没有办法从该实例中获取包名称? docs 表示
The Python code generated by the protocol buffer compiler is completely unaffected by the package name defined in the .proto file.
这是否意味着没有办法从 python protobuf 实例中获取包名称?
如果我有一个 protobuf 对象 response
print type(response)
打印
<class 'weather_pb2.WeatherReply'>
和
print response.DESCRIPTOR.full_name
打印
weather.WeatherReply
weather
是在定义 WeatherReply 的地方指定的包名称。
如果我有一个 protobuf 实例,有没有办法从该实例中获取包名称? docs 表示
The Python code generated by the protocol buffer compiler is completely unaffected by the package name defined in the .proto file.
这是否意味着没有办法从 python protobuf 实例中获取包名称?
如果我有一个 protobuf 对象 response
print type(response)
打印
<class 'weather_pb2.WeatherReply'>
和
print response.DESCRIPTOR.full_name
打印
weather.WeatherReply
weather
是在定义 WeatherReply 的地方指定的包名称。