title: TypeError: write() argument 1 must be unicode, not str
body: <p>I'm trying import a text file and save it on my desktop, but the text is in "utf-8" (there is this information in the book), so when I save without encoding the text has many strange characters, but when I try to save with explicit encoding this error appears:</p>
  
  <blockquote>
  <pre><code>Traceback (most recent call last):
  
  File "C:/Users/Unidas/Semestre/ABC/8.1.py", line 14, in n_palabras
  
  libro.write(archivo.read())
  
  TypeError: write() argument 1 must be unicode, not str
  </code></pre>
  </blockquote>
  
  <p>The code:</p>
  
  <pre><code>def n_palabras(x):
      import urllib2
      import io
      import string
  
      archivo = urllib2.urlopen(x)
      libro = io.open("alice.txt", "w", encoding="utf8")
      libro.write(archivo.read())
      libro.close()
  </code></pre>
  
  <p>How can I save this file with encoding utf-8? 
  I'm using Pycharm with Python 2.7</p>