RE: Python discard extra information

  • From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 10 Feb 2010 21:41:17 -0500

So do this 

Print response["responseData"]: ["translatedText"]

 

That should print what you want because its coming in as a dictionary of 
dictionaries it looks like.

 

 

From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Storm Dragon
Sent: Wednesday, February 10, 2010 9:09 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: Python discard extra information

 

Hi,
Here's the output:
{"responseData": {"translatedText":"Hola, ¿cómo estás hoy?"}, 
"responseDetails": null, "responseStatus": 200}
Here's the part I need in this version of the program, if the text variable 
changes, so does the required output:
Hola, ¿cómo estás hoy?
thanks
Storm


 

 
-- 
Follow me on Twitter:
http://www.twitter.com/stormdragon2976
My blog, Thoughts of a Dragon:
http://www.stormdragon.us/
What color dragon are you?
http://quizfarm.com/quizzes/new/alustriel07/what-color-dragon-would-you-be/

On Wed, 2010-02-10 at 17:50 -0800, R Dinger wrote:



 

What other stuff are you getting? 

  

What exactly does your program output in the print statement? 

  

Richard 

----- Original Message ----- 

From: Storm <mailto:stormdragon2976@xxxxxxxxx>  Dragon 

To: programmingblind@xxxxxxxxxxxxx 

Sent: Wednesday, February 10, 2010 4:55 PM 

Subject: Python discard extra information 

 

Hi,
I have written a small program to translate from english to another language, 
in this instance, Spanish. The problem is, it returns some other stuff that I 
don't need. How can I get just the translated text witout the other stuff? I 
only want to use standard libraries and keep it as short as possible. Thanks 
for the help. Here's the code:
import urllib
text = "hello, how are you today?"
languageCode = 'es'
newText = 
urllib.urlopen("//ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=";
 + urllib.quote(text) + "&langpair=en|" + urllib.quote(languageCode)).read()
print newText

Thanks
Storm


 

 
-- 
Follow me on Twitter:
http://www.twitter.com/stormdragon2976
My blog, Thoughts of a Dragon:
http://www.stormdragon.us/
What color dragon are you?
http://quizfarm.com/quizzes/new/alustriel07/what-color-dragon-would-you-be/





 

Other related posts: