Python通过TCP发送字典 [英] Python sending dictionary through TCP

查看:681
本文介绍了Python通过TCP发送字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是python初学者,我很好奇如何通过TCP发送字典

I'm a python beginner, and I'm curious how can I send a dictionary through TCP

推荐答案

您应使用 pickle :

import pickle
dict = {...}
tcp_send(pickle.dumps(dict))

另一端:

import pickle
dict = pickle.loads(tcp_recieve())

如果另一端不是用python编写的,则可以使用数据序列化格式,例如 xml json

If the other end is not written in python, you can use a data serialization format, like xml, json or yaml.

这篇关于Python通过TCP发送字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆