title: python 3.x and urllib
body: <p>hi i have a problem with my code im using python 3.6 and i open a file .txt and read the text for send to my urllib.request.urlopen() but i have a error i known that is for my txt file has spaces and \n but in python 2.7 work perfectly
  here is my code :</p>
  
  <pre><code>import urllib.request
  import urllib.parse
  
  def readtext():
          quotes = open("C:/Users/sdand/Documents/Python/udacity/curse.txt")
          contents_of_files = quotes.read()
          print(contents_of_files)
          quotes.close()
          check_profanity(contents_of_files)
  
  def check_profanity(text):
          req = urllib.request.urlopen("http://www.wdylike.appspot.com/?q="+text)
          output = req.read()
          req.close()
  
  
  readtext()
  </code></pre>
  
  <p>and this is my error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/Users/sdand/Documents/Python/udacity/profanity.py", line 17, in &lt;module&gt;
      readtext()
    File "C:/Users/sdand/Documents/Python/udacity/profanity.py", line 9, in readtext
      check_profanity(contents_of_files)
    File "C:/Users/sdand/Documents/Python/udacity/profanity.py", line 12, in check_profanity
      req = urllib.request.urlopen("http://www.wdylike.appspot.com/?q="+text)
    File "C:\Program Files\Python36\lib\urllib\request.py", line 223, in urlopen
      return opener.open(url, data, timeout)
    File "C:\Program Files\Python36\lib\urllib\request.py", line 532, in open
      response = meth(req, response)
    File "C:\Program Files\Python36\lib\urllib\request.py", line 642, in http_response
      'http', request, response, code, msg, hdrs)
    File "C:\Program Files\Python36\lib\urllib\request.py", line 570, in error
      return self._call_chain(*args)
    File "C:\Program Files\Python36\lib\urllib\request.py", line 504, in _call_chain
      result = func(*args)
    File "C:\Program Files\Python36\lib\urllib\request.py", line 650, in http_error_default
      raise HTTPError(req.full_url, code, msg, hdrs, fp)
  urllib.error.HTTPError: HTTP Error 400: Bad Request
  </code></pre>
  
  <p>i appreciate you help thank you</p>