Bing's simple English dictionary Tool

Source: Internet
Author: User

Bing's simple English dictionary Tool

Today, I saw "simple translation tool-bing dictionary third-party API usage method" written by Yuan youxin baishui. It feels very good, so I wrote one using Python. The source code is as follows:

1 import urllib. request 2 import json 3 4 serviceurl = 'HTTP: // xtk.azurewebsites.net/BingDictService.aspx? Word = '5 6 while True: 7 word = input ('Enter the English word: ') 8 if len (Word) <1: 9 break10 url = serviceurl + word11 try: 12 uh = urllib. request. urlopen (url) 13 failed T: 14 print ('api error, Please retry ') 15 continue16 data = uh. read () 17 try: 18 js = json. loads (data. decode ('utf-8') 19 Response T: 20 js = ''21 22 if (js ["pronunciation"] = None ): 23 print ("no matching words found") 24 25 else: 26 print ("Voiceover: [", js ["pronunciation"] ["AmE"],
"] English: [", js ["pronunciation"] ["BrE"], "] \ n") 27 for de in js ["defs"]: 28 print (de ["pos"], de ["def"]) 29 print ("\ n example") 30 for sam in js ["sams"]: 31 print ("en:", sam ["eng"]) 32 print ("Chinese:", sam ["chn"], "\ n") 33 continue

The running result is as follows:

Enter the English word: python
Meyin: ['Pa 0000θ 0000n] English: ['Pa 0000θ (0000) n]

N. Python; snake
Web python, Python, and pysen

Example
En: Serpent blood spurted through the air, and in a minute, the huge python was dead.
Chinese: Snake blood is sprayed in the air, and soon the python will die.

En: Suggests that Python Web services implementations were not the only ones having trouble with the air fare quote service.
Chinese: It is pointed out that the implementation of PythonWeb service is not the only one that has difficulties in using the ticket quotation service.

En: Another idea is to require python owners to have their pets fitted with microchips.
Chinese: Another idea is to enable the snake owner to include their pets with microchips.

En: A practice millennium python seeing, changes into an elegant young man, spits into the borneol in his mouth.
Chinese: the giant anchor who has been practicing for thousands of years sees him as a young man and then spit him in his mouth.

En: maid to the meaning threat implicit in Python by handing out a larger notional punishment to a lawbreaker.
Chinese: the responses of the participants are an implicit threat in Python. A larger name is used to send a penalty to the pener.

En: Quite a number of Python programmers have recommended Spark to me.
Chinese: Many Python programmers recommend Spark to me.

En: Zhu went out to investigate, and there, a few paces from his door, he saw a huge python!
Chinese: I wish to go out and check it. Just a few steps away at the door, he saw a python!

En: The bils disappeared, and the couple found a lumpy-looking carpet python nearby.
Chinese: the ball disappeared, but the couple found a uneven carpet anchor nearby.

En: So, in a second study they used a description of a Monty Python sketch which participant ipants weren't told was supposed to be a joke.
Chinese: So In the second experiment, they used a sketch describing python, and the participants did not think it should be a joke.

En: The scripts directory contains python scripts used to install and uninstall the application.
Chinese: The Script directory contains python scripts used to install and uninstall applications.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.