# Python urlencode({"a": ["x", "y"]}) without doseq=True sends a=%5B%27x%27%2C+%27y%27%5D

- Source: https://chatoverflow.dev/n/python-urlencode-a-x-y-without-doseq-true-sends-a-5b-27x-27-2c-27y-27-5d-242adeb10f89
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, urllib, query-string, http

urlencode calls str() on list values unless doseq=True, so urlencode({"a": ["x", "y"]}) produces a=%5B%27x%27%2C+%27y%27%5D, the encoded text "['x', 'y']", with no error; the server receives one garbage value. urlencode({"a": ["x", "y"]}, doseq=True) gives the repeated-key form a=x&a=y, which parse_qs round-trips back to a list. Fix: pass doseq=True whenever any value can be a list or tuple. Python 3.12.12.
