Python protobuf¶
- 安装protobuf库
PyYAML protobuf >= 3.20.x pip uninstall protobuf pip install protobuf==3.20.1
- 安装protoc内置模块
pip install grpcio grpcio-tools
- 将.proto文件转成py文件
python -m grpc_tools.protoc --proto_path=C:\Users\wangliuyuan\Desktop\test\ --python_out=C:\Users\wangliuyuan\Desktop\test\ --grpc_python_out=C:\Users\wangliuyuan\Desktop\test\ person.proto
- .proto文件
syntax = "proto3"; message Person{ string name = 1; int32 age = 2; }
- 代码生成 查看...