python发送的数据格式不对,本来期望应该是发送
entity.subReqID = 1
entity.userName = "H2901"
entity.productName = "qao"
entity.address = "guangzhou"
这样的字符串。但是发送的却是
b'\x08\x01\x12\x05H2901\x1a\x03qao"\tguangzhou'
导致了Android端解码失败。
python发送代码:
entity = SubscribeRespProto_pb2.SubscribeRespProto()
entity.subReqID = 1
entity.userName = "H2901"
entity.productName = "qao"
entity.address = "guangzhou"
content = entity.SerializeToString()
print(content)
proto.transport.write(content)
print ('send to', self.transport.client)
python发送的protobuf格式不对
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- oyljerry 2016-09-29 09:30关注
protobuf本来就会编码,你接收的时候,看解码是否正确。或者用自带的解码工具看看是否正确
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决评论 打赏 举报无用 1