Python 使用websocket时发生“TypeError:需要浮动”

Python 使用websocket时发生“TypeError:需要浮动”,python,python-2.7,websocket,urllib2,Python,Python 2.7,Websocket,Urllib2,我遇到了TypeError:当我尝试使用websocket.create\u connection创建连接时,需要一个float 我看到的例外情况是: File "try.py", line 268, in <module> ws = websocket.create_connection(full_url, headers_conn1) File "/usr/local/lib/python2.7/dist-packages/websocket/_core.py",

我遇到了TypeError:当我尝试使用websocket.create\u connection创建连接时,需要一个float

我看到的例外情况是:

  File "try.py", line 268, in <module>
    ws = websocket.create_connection(full_url, headers_conn1)
  File "/usr/local/lib/python2.7/dist-packages/websocket/_core.py", line 487, in create_connection
    websock.connect(url, **options)
  File "/usr/local/lib/python2.7/dist-packages/websocket/_core.py", line 211, in connect
    options.pop('socket', None))
  File "/usr/local/lib/python2.7/dist-packages/websocket/_http.py", line 71, in connect
    sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
  File "/usr/local/lib/python2.7/dist-packages/websocket/_http.py", line 106, in _open_socket
    sock.settimeout(timeout)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
TypeError: a float is required
知道我错过了什么吗?我看到了链接,但我不确定如何在我的案例中应用相同的解决方案。

似乎将超时值作为第二个参数。在您的例子中,header_conn被解释为超时参数

试一试

ws = websocket.create_connection(full_url, header=header_conn)
ws = websocket.create_connection(full_url, header=header_conn)