A
A
alekssamos2020-08-19 07:19:12
Python
alekssamos, 2020-08-19 07:19:12

How to pass array to url?

>>> import urllib.parse
>>> data = {
... "comments[]":"one",
... "comments[]":"two",
... "comments[]":"three"
... }
>>> data
{'comments[]': 'three'}
>>> urllib.parse.urlencode(data)
'comments%5B%5D=three'
>>>

How to make it:
'comments%5B%5D=one&comments%5B%5D=two&comments%5B%5D=three'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-08-19
@alekssamos

1. You can't make a dictionary with the same keys
2. Correct 3. We read the docs and see what needs to be added doseq=True {'comments[]': ['one', 'two', 'three']}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question