title: Python not recognizing Unicode in a text file
body: <p>I tried to read a log file which has Unicode texts, but couldn't print encoded strings which are Korean words. I would know What was wrong? </p>
  
  <p>The codes are as follows:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  import yaml
  
  path = "./mylog.log"
  mylog = open( path, "r")
  for i in mylog:
      message = i.split("app[web.1]:")[1]
      message = yaml.load(message)  # text -&gt; dict
      print message
      mytext = message["u'content'"]
      print mytext.encode('utf-8')
      print isinstance(mytext, unicode)
  </code></pre>
  
  <p>The results of the codes are as below:</p>
  
  <pre><code>{"u'content'": "u'\\uc131\\uacfc'", "u'type'": "u'text'", "u'user_key'": "u'ADAgPNQ04'"}
  
  u'\uc131\uacfc'
  </code></pre>
  
  <p>False</p>
  
  <pre><code>{"u'content'": "u'\\uc131\\uacfc'", "u'type'": "u'text'", "u'user_key'": "u'ADAgPNQ04'"}
  
  u'\uc131\uacfc
  </code></pre>
  
  <p>'
  False</p>
  
  <p>It seems that my text was not recognized as Unicode,</p>
  
  <p>If I run similar codes in Python console, I got the correct result:</p>
  
  <pre><code>In[1]: text = u'\uc131\uacfc'   
  In[2]: print text
  </code></pre>
  
  <p>성과     # a Korean word</p>
  
  <p>mylog.log:</p>
  
  <pre><code>2016-11-22T07:35:30.197270+00:00 app[web.1]: {u'content': u'\uc131\uacfc', u'user_key': u'ADAgPNQ04', u'type': u'text'}
  
  2016-11-22T09:55:09.994257+00:00 app[web.1]: {u'content': u'\uc131\uacfc', u'user_key': u'ADAgPNQ04', u'type': u'text'}
  </code></pre>