我尝试通过套接字连接发送列表,但是我遇到了Can't convert 'bytes' object to str
错误。
while True:
try:
data = stream.read(CHUNK)
except IOError:
pass
else:
decoded = numpy.fromstring(data, dtype=numpy.float32)
i = json.dumps(decoded.tolist())
jsonDecoded = json.loads(i)
jsonS = "%s" % jsonDecoded
ws.send(jsonS)
我还尝试了jsonS = "{}".format(jsonDecoded, 'utf-8')
以及"".join(str(x) for x in jsonDecoded)
,这给了我同样的错误。 str(jsonDecoded, 'utf-8')
也不起作用。
有什么想法吗?
这是完整的堆栈跟踪
Traceback (most recent call last):
File "C:\Users\Bart\Dropbox\Redux\streaming\streaming\streamingdata.py", line 39, in <module>
ws.send(jsonS)
File "C:\Python33\lib\site-packages\websocket_client_py3-0.14.1-py3.3.egg\websocket\__init__.py", line 655, in send
return self.send_frame(frame)
File "C:\Python33\lib\site-packages\websocket_client_py3-0.14.1-py3.3.egg\websocket\__init__.py", line 674, in send_frame
data = frame.format()
File "C:\Python33\lib\site-packages\websocket_client_py3-0.14.1-py3.3.egg\websocket\__init__.py", line 340, in format
frame_header += struct.pack("!H", length)
TypeError: Can't convert 'bytes' object to str implicitly
答案 0 :(得分:0)
套餐不是最新的。请从Github repo更新到最新版本。