Thank you for your reply. I am trying to load saved data. I use the
following script but it is empty after I run it:
import example_pb2
with open('saved_data.protobin','rb') as f:
data = f.read()
msg = example_pb2.Sensor()
msg.ParseFromString(data) # or msg.FromString(data)
Do you know what I'm doing wrong?
On Thursday, April 9, 2020 at 1:35:34 PM UTC-4, Mac Pham wrote:
>
>
> From C++ I used SerializeToString
>
> * Ex:*
> string output;
>
> response->SerializeToString(&output);
>
>
> In python:
>
> if I use UDP to receive it , I use PBWrapper.FromString(message[0]) where
> message contains data I received from UDP socket
>
> For TCP just use PBWrapper.FromString(message)
>
>
> And it worked for me.
>
>
> -Tom
>
>
> On Monday, May 7, 2018 at 2:26:07 AM UTC-7, Silpa Ks wrote:
>>
>>
>> Hi,
>>
>> I'm facing problem in parsing binary file containing protobuf data in
>> array format. When I used the python API, ParseFromString output was
>> always zero or none. The serialized protobuf data in the binary file was
>> generated using C++ API, SerializeToArray. But to parse the bin file, I
>> want to use python for parsing. But in python I couldn't find any API to
>> parse serialized protobuf data as array in binary file. Is there any python
>> API to resolve this issue? Can anyone please suggest a solution for this?
>>
>
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/protobuf/83b179ee-6d76-4651-82a9-99cc95f0d9fb%40googlegroups.com.