TypeError: compile() expected string without null bytes
<p>I am trying to translate a string using google translate API.    </p>

<p>enter code here</p>

<pre><code>#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys
import urllib
import urllib2

import ast


url = 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&amp;q='+urllib.quote(' '.join(sys.argv[3:]))                   +'&amp;langpair='+sys.argv[1]+'%7C'+sys.argv[2] 
print url

transtext =urllib2.urlopen(urllib2.Request(url)).read()
content=ast.literal_eval(transtext)

print  content['responseData']['translatedText']
</code></pre>

<p><strong>python testURL.py hi en  'नमस्ते'</strong></p>

<p>this is the url given .</p>

<p><a href="http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&amp;q=%E0%A4%A8%E0%A4%AE%E0%A4%B8%E0%A5%8D%E0%A4%A4%E0%A5%87&amp;langpair=hi%7Cen" rel="nofollow">http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&amp;q=%E0%A4%A8%E0%A4%AE%E0%A4%B8%E0%A5%8D%E0%A4%A4%E0%A5%87&amp;langpair=hi%7Cen</a>
If we check the above url we can see the Output is Hello  </p>

<pre><code>{"responseData": {"translatedText":"Hello"}, "responseDetails": null, "responseStatus": 200}
</code></pre>

<p>this is in string format so im trying to convert it to dictionary format using ast.literal_eval and then acess the data in dictionary by  content['responseData']['translatedText'] but following error occurs </p>

<p><em>Error:</em></p>

<pre><code>    content=ast.literal_eval(transtext)
  File "/usr/lib/python2.6/ast.py", line 49, in literal_eval
    node_or_string = parse(node_or_string, mode='eval')
  File "/usr/lib/python2.6/ast.py", line 37, in parse
    return compile(expr, filename, mode, PyCF_ONLY_AST)
TypeError: compile() expected string without null bytes
</code></pre>

<p>python version 2.6 and OS Ubuntu 9.10</p>

<p>Please suggest some solution for this.Thank you</p>
