pip install socket
pip install websocket
pip install websocket-client
socket
import socketAddress = ('127.0.0.1', 3000) # Socket server address, modify according to your own situations = socket.socket(socket.AF_INET, socket.SOCK_STREAM)s.connect(Address) # try to connect to the servermsg="test"s.sendall(msg.encode())
websocket
from websocket import create_connectionimport jsonurl = 'ws://127.0.0.1:3000'data = '{}'ws = create_connection(url)msg=["Send",{"content":"test"},1]ws.send(json.dumps(msg))
Rewrite the query interface C
The terminal input has been so