title: Build query string using urlencode python
body: <p>I am trying to build a url so that I can send a get request to it using <code>urllib</code> module.</p>
  
  <p>Let's suppose my <code>final_url</code> should be </p>
  
  <pre><code>url = "www.example.com/find.php?data=http%3A%2F%2Fwww.stackoverflow.com&amp;search=Generate+value"
  </code></pre>
  
  <p>Now to achieve this I tried the following way:</p>
  
  <pre><code>&gt;&gt;&gt; initial_url = "http://www.stackoverflow.com"
  &gt;&gt;&gt; search = "Generate+value"
  &gt;&gt;&gt; params = {"data":initial_url,"search":search}
  &gt;&gt;&gt; query_string = urllib.urlencode(params)
  &gt;&gt;&gt; query_string
  'search=Generate%2Bvalue&amp;data=http%3A%2F%2Fwww.stackoverflow.com'
  </code></pre>
  
  <p>Now if you compare my <code>query_string</code> with the format of <code>final_url</code> you can observer two things</p>
  
  <p>1) The order of params are reversed instead of <code>data=()&amp;search=</code> it is <code>search=()&amp;data=</code></p>
  
  <p>2) <code>urlencode</code> also encoded the <code>+</code> in <code>Generate+value</code></p>
  
  <p>I believe the first change is due to the random behaviour of dictionary. So, I though of using <a href="https://stackoverflow.com/questions/6083531/python-reverse-dictionary-order"><code>OrderedDict</code> to reverse the dictionary</a>. As, I am using <code>python 2.6.5</code> I did </p>
  
  <pre><code>pip install ordereddict
  </code></pre>
  
  <p>But I am not able to use it in my code when I try </p>
  
  <pre><code>&gt;&gt;&gt; od = OrderedDict((('a', 'first'), ('b', 'second')))
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  NameError: name 'OrderedDict' is not defined
  </code></pre>
  
  <p>So, my question is what is the correct way to use <code>OrderedDict</code> in python 2.6.5 and how do I make <code>urlencode</code> ignores the <code>+</code> in <code>Generate+value</code>.</p>
  
  <p>Also, is this the correct approach to build <code>URL</code>.</p>