5

このように Google Protobuf を使用して構造をシリアル化する C++ のアプリケーションがあります。

int len = mdd.ByteSize();
char* buf = (char *)malloc(len);
mdd.SerializeToArray(buf, len);

これをpythonからシリアル化解除したい:

import  marketdata_pb2
...
md = marketdata_pb2.MarketDataDepth()
#what goes here? I don't see a marketdata_pb2.parsefromarray()
4

1 に答える 1

4

を探していmd.ParseFromString(some_string_of_bytes)ます。Python 2.x では、「何らかのバイト文字列」はstr.

https://developers.google.com/protocol-buffers/docs/pythontutorial

于 2012-09-17T04:29:03.003 に答える