
websockets13.01结果如上。另外存在不同版本websockets代码无法重复使用,在于引用变量数量不同。具体如下,也可见官方文档:websockets 15.0.1 documentation
#电脑端服务器 websockets13.01
import asyncio
import websockets
async def echo(websocket, path):
async for message in websocket:
print(f"Received message: {message}")
await websocket.send(f"Echo: {message}")
start_server = websockets.serve(echo, "0.0.0.0", 5678)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
#树莓派客户端,电脑IP替换为你电脑的IP即可 websockets13.01
import asyncio
import websockets
async def main():
async with websockets.connect("ws://电脑IP:5678") as websocket:
message = "Hello, server!"
await websocket.send(message)
print(f"Se

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



