Encoding 2D List

If you only want the peer to be able to print, or send back the 2D list, you can directly send a string representation:

clientSocket.send(str(input).encode())

If you want it to be able to process the data as a 2D list, you should serialize the list, for example with json:

clientSocket.send(json.dumps(input).encode())

Then you can retrieve the list with:

list2D = json.loads(connectionSocket.recv(1024))

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top