Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fill StringValue in protobuf in python

How to fill StringValue in protobuf (programming in python)

message event {
    string id = 1; 
    google.protobuf.StringValue test = 2;
}
like image 459
charley Avatar asked Sep 17 '26 17:09

charley


2 Answers

event.test.value = 'test'

Also works. It is more straightforward and doesn't require importing StringValue class.

like image 91
previous_developer Avatar answered Sep 20 '26 12:09

previous_developer


After fighting for a while found the answer

event.test.CopyFrom(wrappers.StringValue(value='test'))
like image 25
charley Avatar answered Sep 20 '26 10:09

charley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!