You can use such a payload as follows:
payload = [ ('fname', 'homer'), ('lname', 'simpson'), ('favefood', 'raw donuts'), ('favefood', 'free donuts'), ] rtt = requests.post("http://httpbin.org/post", data=payload)
But if your case allows, I prefer POST JSON with all the "favefoood" in the list:
payload = {'fname': 'homer', 'lname': 'simpson', 'favefood': ['raw donuts', 'free donuts'] } # 'json' param is supported from requests v2.4.2 rtt = requests.post("http://httpbin.org/post", json=payload)
Or, if JSON is not preferred, combine all the "favefood" into a string (carefully select a separator):
payload = {'fname': 'homer', 'lname': 'simpson', 'favefood': '|'.join(['raw donuts', 'free donuts'] } rtt = requests.post("http://httpbin.org/post", data=payload)
source share