Skip to content

Commit f95bfbb

Browse files
Added terminal dictionary
1 parent 2657403 commit f95bfbb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import urllib
2+
import json
3+
4+
title = raw_input("Enter word to search: ")
5+
print "Word: ",title
6+
7+
#stores the json formatted output to a variable
8+
url = 'http://glosbe.com/gapi/translate?from=eng&dest=eng&\
9+
format=json&phrase='+title+'&pretty=true'
10+
11+
#json representation of url is stored in variable result
12+
result = json.load(urllib.urlopen(url))
13+
14+
#get the first text in "meaning" in "tuc" from result
15+
try:
16+
print "Meaning: ", result["tuc"][0]["meanings"][0]["text"]
17+
except Exception as e:
18+
print "Error!"
19+

0 commit comments

Comments
 (0)