Python Encode Spaces are incorrectly encoded
<p>I have a dictionary as follows </p>

<pre><code>params = {
        'response_type': 'token',
        'client_id': o_auth_client_id,
        'redirect_url': call_back_url,
        'scope': 'activity heartrate location'

}
print urllib.urlencode(params)
</code></pre>

<p>and um encoding it </p>

<p>but in results </p>

<blockquote>
  <p>redirect_url=http%3A%2F%2F127.0.0.1%3A8084%2Fagile_healtg%2Faccess_token%2F&amp;response_type=token&amp;client_id=xxxxxx&amp;scope=activity+heartrate+location</p>
</blockquote>

<p>um getting something like above 
Unfortunately spaces are encoded as + signs </p>

<p>but the results should be </p>

<blockquote>
  <p>scope=activity%20nutrition%20heartrate</p>
</blockquote>

<p>how may I achieve the correct encode for spaces in python ?</p>

<p>Check the documentation for the <a href="https://docs.python.org/2/library/urllib.html#urllib.urlencode" rel="nofollow">urlencode</a>.</p>

<p>The <code>quote_plus</code> method is used to change the spaces to plus symbol when it comes to passing key values. You can use <code>unquote_plus</code> method to remove the plus symbols and then <code>quote</code> to encode it in the format you want.</p>

<p><strong>You basically need to use the <code>quote</code> method for your parameters</strong></p>

python encoding urlencode