title: Why does urllib.urlencode add square brackets and single quotes to my dict values?
body: <p>I'm trying to write a script that can parse a url and get the query params from it. So far I've mostly got it, but urllib.urlencode is adding square brackets and single quotes to my values when I think it shouldn't be. This is most likely a misunderstanding on my part, so if someone could explain why this happens and how to avoid it I would really appreciate it. Here is my script:</p>
  
  <pre><code>#/usr/bin/python
  import urlparse
  import urllib
  
  url = 'https://mysite.com?Action=ParseUrl'
  parsed_url = urlparse.urlparse(url)
  query_params = urlparse.parse_qs(parsed_url.query)
  
  query_string = urllib.urlencode(query_params)
  print query_string
  </code></pre>
  
  <p>The resulting output is:</p>
  
  <pre><code>Action=%5B%27ParseUrl%27%5D
  </code></pre>
  
  <p>So you can see that the value of 'Action' has been surrounded by urlencoded [' '] characters. I would like the value of my query_string variable to be :</p>
  
  <pre><code>Action=ParseUrl
  </code></pre>
  
  <p>What can I do to my script to make this happen. I realize I could hack some sort of reg exp to remove the characters, but I would rather understand the fundamental reason of why this is not working the way I want it to so I can avoid this problem in the future.</p>
  
  <p>Thanks!</p>