如何在请求中发布有序参数?
我尝试了以下方法,但它们都不起作用:
payload = dict{('f','1'),('s','2'),('t','3'),('f','4'),('ft','5'),('s','6'),('se','7'),('e':8,'data[1]','9'),('t','10'),('el','1q'),('data[2]','12'),('data[3]','13'),('data[4]','14'),('htmldata[5]','15')}
payload = OrderedDict{('f','1'),('s','2'),('t','3'),('f','4'),('ft','5'),('s','6'),('se','7'),('e':8,'data[1]','9'),('t','10'),('el','1q'),('data[2]','12'),('data[3]','13'),('data[4]','14'),('htmldata[5]','15')}
payload = (('f','1'),('s','2'),('t','3'),('f','4'),('ft','5'),('s','6'),('se','7'),('e':8,'data[1]','9'),('t','10'),('el','1q'),('data[2]','12'),('data[3]','13'),('data[4]','14'),('htmldata[5]','15'))
payload = ([('f','1'),('s','2'),('t','3'),('f','4'),('ft','5'),('s','6'),('se','7'),('e':8,'data[1]','9'),('t','10'),('el','1q'),('data[2]','12'),('data[3]','13'),('data[4]','14'),('htmldata[5]','15')])
我得到的错误是:
SyntaxError: invalid syntax
这一项以随机顺序发布参数,没有错误:
payload = {'f':'1','s':'2','t':'3','f':'4','ft':'5','s':'6','se':'7','e':8,'data[1]':'9','t':'10','el':'1q','data[2]':'12','data[3]':'13','data[4]':'14','htmldata[5]':'15'}
如何使用以下代码发布有序参数?
c = requests.post(url, params = payload)