N
N
NickNameNew2021-08-10 20:27:01
Python
NickNameNew, 2021-08-10 20:27:01

How to deserialize data with Google Protobuf in Python 3?

I searched on the Internet, but Google does not have an up-to-date example, or I'm installing something wrong. The fact that they import it does not find it.
I installed pip install protobuf
https://pypi.org/project/protobuf/

And I looked at the information on the Google website
https://developers.google.com/protocol-buffers/doc...

Maybe someone came across how this data was deserialized?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WhiteApfel, 2021-08-10
@WhiteApfel

Do I understand correctly that it is necessary to decrypt the protobuf binary message without using the .proto scheme? If yes, then there is a good tool https://github.com/nevermoe/protobuf_decoder
Using the official library means generating py-files with the necessary classes, based on which deserialization will take place. Example from their page:

protoc -I=$SRC_DIR --python_out=$DST_DIR $SRC_DIR/addressbook.proto

You can replace environment variables with relative paths for the sake of convenience. And you will need to change the last argument to your proto-file. Then import it into the code and use it, they also have an example https://developers.google.com/protocol-buffers/doc...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question