原请求:
url = "https://test-mmmmm.com/eer/wq"
payload="{\"type\": 1,\"name\": \"测试\"}"
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
报错:
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 20-21: Body ('测试') is not valid Latin-1. Use body.encode('utf-8') if you want to send it encoded in UTF-8.
原因:
payload里面有中文
修改payload为:
payload=payload.encode('utf-8')
即可