开发者

python:send class object in socket.sendto()

开发者 https://www.devze.com 2023-03-18 23:48 出处:网络
开发者_JAVA百科I want to send a class object in socket.sendto(classObject , (host , port)). Basically I want to send some more information with the message.How can I do this.You can\'t. Serialize the
开发者_JAVA百科

I want to send a class object in socket.sendto(classObject , (host , port)).

Basically I want to send some more information with the message.How can I do this.


You can't. Serialize the data before attempting to send it.


Use bits = pickle.dumps(classObject) to send data into socket.sendto(bits , (host , port)). And use classObject = pickle.loads(bits) to get the object after.

0

精彩评论

暂无评论...
验证码 换一张
取 消