python下使用pb
下载安装
brew install protobuf , 其实如果有pip的话
pip install protobuf
pb的压测
ab -n 500 -c 20 -T application/x-protobuf -p ./pbdata_upload.txt "http://xxx:8080/xxx?action=uploadfile&c=client"
其中pbdata_upload.txt,是经过pb序列化后生成的数据
遇到的问题:
-
syntax = "proto2" syntax = "proto3"
-
ImportError: No module named google.protobuf
解决方案:pip install protobuf -
Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'o
.protoc 指定syntax = "proto2" 解决。
https://my.oschina.net/wangande2014/blog/672149
4.生成pb 命令
protoc -I=./ --python_out=./ FootprintDetailPageModel.proto
网友评论