socketio使用回调提示create_client..test()缺少1个必需的位置参数:'ack'
服务器代码:
def test_call_back(text):
print(text)
sio.emit('test', 'test call back', callback=test_call_back)
客户端代码:
@sio.on('test')
def test(data,ack):
print(data)
ack()
运行错误提示:
create_client.<locals>.test() missing 1 required positional argument: 'ack'
我应该如何使用回调?
server code:
def test_call_back(text):
print(text)
sio.emit('test', 'test call back', callback=test_call_back)
cliend code:
@sio.on('test')
def test(data,ack):
print(data)
ack()
run wrong tips:
create_client.<locals>.test() missing 1 required positional argument: 'ack'
How should I use callback?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎正在使用 JavaScript 客户端文档并将其应用到 Python 客户端。 Python 客户端不是克隆版本,因此请使用 Python 文档。对于回调: https://python-socketio.readthedocs.io /en/latest/client.html#event-callbacks。
向另一端返回两个值的示例 ack:
You seem to be using the JavaScript client documentation and applying that to the Python client. The Python client is not a clone, so please use the Python documentation instead. For callbacks: https://python-socketio.readthedocs.io/en/latest/client.html#event-callbacks.
Example ack that returns two values to the other side: