Answers for "dictionaries to http data python"

1

dictionaries to http data python

dictionary = {"a":2,"b":3,"kirekhar":"kireasb"}

#WAY NUMBER ONE:
result = ""
for key,val in zip(dic.keys(),dic.values()):
	result+=key+"="+str(val)+";"
print(result) # OUTPUT : 'a=2;b=3;kirekhar=kireasb;'
requests.post(url, data=result)

#WAY NUMBER TWO:
import json
requests.post(url, data=json.dumps(dictionary))

#WAY NUMBER THREE:
requests.post(url, json=dictionary)
Posted by: Guest on March-12-2021

Code answers related to "dictionaries to http data python"

Python Answers by Framework

Browse Popular Code Answers by Language