Sending multiple POST data items with the same name, using AppEngine

。_饼干妹妹 提交于 2019-12-04 05:17:38

Modify your form_fields dictionary so that fields with the same name are turned into lists, and use the doseq argument to urllib.urlencode:

form_fields = {
   "data": ["foo","bar"]
}

form_data = urllib.urlencode(form_fields, doseq=True)

At this point, form_data is 'data=foo&data=bar', which is what I think you need.

A normal python dict can't handle this sort of thing; use something like a webob.MultiDict:

>>> z = webob.MultiDict([('foo', 'bar'), ('foo', 'baz')])
>>> urllib.urlencode(z)
'foo=bar&foo=baz'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!