urlencode an array of values

后端 未结 5 1672
半阙折子戏
半阙折子戏 2020-12-13 08:25

I\'m trying to urlencode an dictionary in python with urllib.urlencode. The problem is, I have to encode an array.

The result needs to be:

criterias%         


        
5条回答
  •  生来不讨喜
    2020-12-13 09:13

    You can use a list of key-value pairs (tuples):

    >>> urllib.urlencode([('criterias[]', 'member'), ('criterias[]', 'issue')])
    'criterias%5B%5D=member&criterias%5B%5D=issue'
    

提交回复
热议问题