The socket module allows you to send binary strings over the network. Here is a short client example:
Client:
import socket
s = socket.socket()
s.connect(("localhost", 8888))
s.send(b"some data")
response = s.recv(1024)
print(response)
s.close()
Server
import socket
s = socket.socket()
s.bind(("localhost", 8888))
s.listen(1)
while True:
conn, addr = s.accept()
print("got connection from: ", addr)
data = conn.recv(1024)
print("received: ", data)
conn.send(b"server received: " + data)
conn.close()
Both of these code snippets are only minimal and untested.
When developing multiplayer for a game, the largest part is actually the creation and handling of these messages.
What do you want to be sent between server and client? The simplest way is to only send the actions each player chooses (e.g. move north) to the server, where the real game runs, and send the changes (player moves north) to all the client.
It is more complicated if you want one client to also be the server of the game.
The most simple way is to structure the whole gamecode arround the netcode (in my experience). This means seperating the game logic from the user interface. For example, you could always start a server in the background and make every singleplayer game connect to this private server instead of writing a seperate server.
In this case the client only needs to handle the menu, graphics and user input.
If you want your clients to automatically find other games in the LAN, take a look at UDP broadcasting.
For a simple way to convert a python object into a string, use the pickle module (but be aware that this is quite a security risk, so you may want to use other modules for this).
Also, take a look at threading (running multiple functions in paralell) or asynchronous network programming if you want to handle multiple clients at the same time. In python2, there is a SocketServer module for easily handling multple clients in parallel (using the ThreadingMixIn class or how it was named). This module was renamed in py3.