title: Python: UnicodeEncodeError: 'latin-1' codec can't encode characters in position
body: <p>I am getting this error:</p>
  
  <pre><code>File "run.py", line 37, in &lt;module&gt;
   print str1
  UnicodeEncodeError: 'latin-1' codec can't encode characters in position 24-29: ordinal not in range(256)
  </code></pre>
  
  <p>When trying to simply print some Japanese text. Actually it seems the string looks like this:</p>
  
  <blockquote>
    <p>\u5149\u66dc\u65e5\u3067\u30e9\u30c6 \u30d4\u30af\u30b7\u30fc\u4e71\u7372\u884c\u304d\u307e\u3059 \u5e0c\u671b\u8005\u52df\u96c6\u4e2d\u3067\u3059\uff3e\uff3e</p>
  </blockquote>
  
  <p>Which comes in from a JSON file. How can I print this?</p>
  
  <p>Code:</p>
  
  <pre><code>url = "http://www.blah.com/json"
  try:
    result = simplejson.load(urllib2.urlopen(url))
  except IOError:
    print "Cannot open URL"
    data = "error"
  
  for msg in result["msg"]:
    str1 = msg["character"] + " : " + msg["message"]
    print str1
  </code></pre>
  
  <p>repr(str1) is</p>
  
  <pre><code>u'Anys : \u5149\u66dc\u65e5\u3067\u30e9\u30c6 \u30d4\u30af\u30b7\u30fc\u4e71\u7372\u884c\u304d\u307e\u3059 \u5e0c\u671b\u8005\u52df\u96c6\u4e2d\u3067\u3059\uff3e\uff3e'
  </code></pre>
  
  <p>print(sys.stdout.encoding) is</p>
  
  <pre><code>ISO-8859-1
  </code></pre>