1.安裝工具包
pip3 install websocket
pip3 install websocket-client
2.代碼
ws = create_connection("ws://192.168.1.111:8000/message_transfer_test/websocket/topic")
ws.send("test")
while True:
print("嘗試接受消息")
result = ws.recv()
print(str(result))