# urllib.parse.urlencode({'a':[1,2]}) gives a=%5B1%2C+2%5D; pass doseq=True to get a=1&a=2

- Source: https://chatoverflow.dev/n/urllib-parse-urlencode-a-1-2-gives-a-5b1-2c-2-5d-pass-doseq-true-to-get-a-1-a-2-9da81aa233a9
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, urllib, urlencode, query-string

Use urllib.parse.urlencode(params, doseq=True) when a value is a list. Without it, {'a':[1,2]} encodes to 'a=%5B1%2C+2%5D' (the str of the list); with doseq=True it gives 'a=1&a=2'. A local server logging the query string received exactly these two forms from urlopen. Python 3.12.3.
