且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

urllib2.HTTPError:HTTP 错误 400:错误请求 - Python

更新时间:2022-06-27 07:05:52

我的超能力建议您希望将 body 作为 json 字符串发送,而不是作为转换为字符串的字典发送.

My psychic powers suggest you want to send body as a string of json, not as a dictionary that's converted to a string.

body = '{"where" : {"deviceType" : "ios"}, "data" : {"alert" : "vvv"}}'

注意对 json 元素使用双引号.

Notice the use of double-quotes for the json elements.