2023/12/12 LabVIEW2020 with Python 3.6.8實作Protocol buffer序列化流程-建置proto檔並產生Python library (.py)

步驟
1. 撰寫proto檔,將檔案存到D:\Python_Protobuf
2. 將protoc.exe複製到D:\Python_Protobuf目錄下
3. 執行命令提示視窗打開,將路徑指向到D:\Python_Protobuf下
4. 在命令提示視窗輸入”protoc -I=./ –python_out=./ ./helloworld.proto“
5. 如果沒有問題,在D:\Python_Protobuf會有”helloworld_pb2.py“檔案產生
6. 現在就可以在Python IDE下 import “helloworld” 來使用了

syntax = "proto3";

package helloworld_package;
message helloworld
{
    int32 id = 1;
    string name = 2;
    int32 wow = 3;
}

protoc -I=./ –python_out=./ ./helloworld.proto
-I: 是設定來源路徑
–python_out: 用於設定編譯後的輸出結果,如果使用其它語言請使用對應語言的option
最後一個參數是你要編譯的proto文件

One reply on “2023/12/12 LabVIEW2020 with Python 3.6.8實作Protocol buffer序列化流程-建置proto檔並產生Python library (.py)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *