I try to run this (geth is started with rpc on http://localhost:8545)
#!/usr/bin/env python3
from urllib.parse import urlencode
from urllib.request import Request, urlopen
rpc = "http://localhost:8545"
print(urlopen(Request(rpc,urlencode({"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":42}).encode(),headers={'Content-Type': 'application/json'}), timeout=60).read().decode())
It print :
{"jsonrpc":"2.0","error":{"code":-32600,"message":"invalid character 'j' looking for beginning of value"}}