上一篇
websocket接口调用
websocket.py
from ws4py.client.threadedclient import WebSocketClient class CG_Client(WebSocketClient): def opened(self): req = "Hello, World" self.send(req) def closed(self, code, reason=None): print("Closed down:", code, reason) def received_message(self, resp): result = str(resp) print(" 返回 "+result) if __name__ == '__main__': ws = None try: ws = CG_Client('ws://echo.websocket.org') ws.connect() ws.run_forever() except KeyboardInterrupt: ws.close()
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/20483.html