title: How to convert unicode characters into their respective symbols in python?
body: <p>I have a text file which contains unicode characters in the following format:</p>
  
  <pre><code>\u0935\u094d\u0926\u094d\u0928\u094d\u0935\u094d\u0926\
  </code></pre>
  
  <p>I want to convert it into devnagri characters in the following format:</p>
  
  <pre><code>वर्जनरूपमिति दर्शित्म् । स पूरुषः अमृतत्वाय कल्पते व्द्न्व्द
  </code></pre>
  
  <p>and then write it to a file.
  Presently my code </p>
  
  <pre><code>encoded = x.encode('utf-8')
  print (encoded.decode('unicode-escape'))
  </code></pre>
  
  <p>can print the devnagri characters in the terminal. However when I try to write it to a file using </p>
  
  <pre><code>text = 'target:'+encoded.decode('unicode-escape')+'\n'
  fileid.write(text)
  </code></pre>
  
  <p>I am getting the following error.</p>
  
  <pre><code>'ascii' codec can't encode characters in position 7-18: ordinal not in range(128)
  </code></pre>
  
  <p>Can anybody please help me?</p>