You need to serialize your data first. There are several ways to do this, the most common probably JSON, XML and (python specific) pickles. Or your own custom serialization.
The basic idea is: Serialize your data, send it, receive it, deserialize it again.