繁体   English   中英

在c ++中序列化,在python中反序列化?

[英]Serialize in c++, deserialze in python?

我有一个C ++应用程序,使用像这样的Google Protobuf序列化结构

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()

您正在寻找md.ParseFromString(some_string_of_bytes) 在Python 2.x中,“一些字节串”是一个str

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM