title: Convert string with spaces to html url in python 3.3
body: <p>I'm trying to convert a YQL string with spaces to html code. </p>
  
  <p>Here's the YQL string I'm using:</p>
  
  <pre><code>select * from yahoo.finance.historicaldata where symbol in ("MSFT", "AAPL") and startDate = "2010-10-01" and endDate = "2010-10-05"
  </code></pre>
  
  <p>Here's the url code that needs to come out:</p>
  
  <pre><code>http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20in%20(%22MSFT%22%2C%20%22AAPL%22)%20and%20startDate%20%3D%20%222010-10-01%22%20and%20endDate%20%3D%20%222010-10-05%22&amp;format=json&amp;diagnostics=true&amp;env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&amp;callback=
  </code></pre>
  
  <p>I've been trying to do this with <em>urllib.parse.urlencode</em> but have not had any luck.</p>
  
  <p>I can get up to "<a href="http://query.yahooapis.com/v1/public/yql" rel="nofollow">http://query.yahooapis.com/v1/public/yql</a>?" but afterwards it starts to break down. Is there a pythonesque way to do this that I'm just missing?</p>
  
  <p>Thank you!</p>