Python 使用请求将列表和dict作为参数发送到REST服务

Python 使用请求将列表和dict作为参数发送到REST服务,python,web-services,rest,Python,Web Services,Rest,我有一个虚拟web服务,它以列表形式接收参数,以dict形式接收参数: class Dummy: exposed = True def POST(self, l, d): return str(l) + '----' + str(d) 我使用发送post请求: l = [1, 2, 3] d = ['1':1, '2':2, '3':3] r = requests.post('http://localhost:8080/Dummy/', {'l':l, 'd':d}) print r

我有一个虚拟web服务,它以列表形式接收参数,以dict形式接收参数:

class Dummy:
exposed = True

def POST(self, l, d):
    return str(l) + '----' + str(d)
我使用发送post请求:

l = [1, 2, 3]
d = ['1':1, '2':2, '3':3]
r = requests.post('http://localhost:8080/Dummy/', {'l':l, 'd':d})
print r.text
我收到的结果是u[u'1',u'2',u'3']-[u'1',u'3',u'2'],这意味着只发送dict的密钥。我目前的解决方案是发送一个表示dict的字符串,并在服务器端将其转换回dict


我想知道是否有办法通过POST将列表和dict发送到web服务。

来自请求的文档具有


dict将作为表单发送。

您可能应该使用JSON。