Python sending dictionary through TCP

前端 未结 1 1310
抹茶落季
抹茶落季 2021-02-15 08:56

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

相关标签:
1条回答
  • 2021-02-15 09:39

    You should serialize it with pickle:

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

    And on the other end:

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

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

    0 讨论(0)
提交回复
热议问题