📜  字典到 http 数据 python 代码示例

📅  最后修改于: 2022-03-11 14:46:04.488000             🧑  作者: Mango

代码示例1
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)