本文主要是介绍on_close() missing 1 required positional argument: 'ws',希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
-
问题描述
class Something():def on_message(self,ws, message):pass...def main(self):websocket.enableTrace(True)ws = websocket.WebSocketApp("wss://stream.binance.com:9443/ws/btcusdt@trade",on_message = self.on_message,on_error = self.on_error,on_close = self.on_close)
将websocket实例写入一个类,此时调用self.on_message出现如题问题。
-
解决方案
class Something():def on_message(self, message): # 将ws去掉,self占位wspass...def main(self):websocket.enableTrace(True)ws = websocket.WebSocketApp("wss://stream.binance.com:9443/ws/btcusdt@trade",on_message = self.on_message,on_error = self.on_error,on_close = self.on_close)
-
References
- Python3 Websocket Callback cannot assign Class Member Functions
- websocket-client==0.49.0 -> _on_open() missing 1 required positional argument: ‘ws’ #30
这篇关于on_close() missing 1 required positional argument: 'ws'的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!