File "D:\Python\Python36\lib\http\client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "D:\Python\Python36\lib\http\client.py", line 1284, in _send_request
body = _encode(body, 'body')
File "D:\Python\Python36\lib\http\client.py", line 161, in _encode
(name.title(), data[err.start:err.end], name)) from None
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 195-202: Body ('这个是什么颜色呢') is not valid Latin-1. Use body.encode('utf-8') if you want to send it encoded in UTF-8.
解决办法:在data上加上encode('utf-8'),即data.encode('utf-8')
网友评论