📜  派 | websocket - 客户端 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:44.797000             🧑  作者: Mango

代码示例1
#!/usr/bin/env python

import asyncio
import websockets

async def hello(uri):
    async with websockets.connect(uri) as websocket:
        await websocket.send("Hello world!")
        await websocket.recv()

asyncio.get_event_loop().run_until_complete(
    hello('ws://localhost:8765'))