如何修复Websockets“ UnicodeEncodeError”?

时间:2019-10-29 22:22:58

标签: python python-3.x websocket

我正在打印使用websockets python模块创建的websocket的响应。在来自websocket的响应之一上,抛出以下错误。

我复制了以前有效的代码版本,但现在已经停止工作。

Traceback (most recent call last):
  File "C:\Users\\PycharmProjects\Project\main.py", line 10, in <module>
    Client.run()
  File "C:\Users\\PycharmProjects\Project\client.py", line 25, in run
    asyncio.get_event_loop().run_until_complete(task)
  File "C:\Users\\AppData\Local\Programs\Python\Python37-32\lib\asyncio\base_events.py", line 579, in run_until_complete
    return future.result()
  File "C:\Users\\PycharmProjects\Project\client.py", line 41, in web_socket
    print(response)
  File "C:\Users\\AppData\Local\Programs\Python\Python37-32\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f4bb' in position 361: character maps to <undefined>
[Finished in 3.34s]

不应该抛出错误

0 个答案:

没有答案