def display_web_explains(word): myfanyi = fanyi_dictionary(word) if myfanyi.errorCode == "0": web_explains = myfanyi.web_explains() print "\n\033[22;36;40m网络词组:\033[0m" for explain in web_explains.keys(): print "\033[1;36;40m%s\033[0m" % explain for value in web_explains[explain]: print value
def fanyi_lookup(word): mydictionary = fanyi_dictionary(word) if mydictionary.errorCode == "0": if mydictionary.translation == "": print "ldict: 呃!真的有这个词?(⊙o⊙)" else: print "\033[1;34;40m%s\033[0m" % word if mydictionary.phonetic != "": print "\033[1;31;40m[%s]\033[0m" % mydictionary.phonetic print "\n有道翻译:" print "\033[1;36;40m%s\033[0m" % mydictionary.translation
def look_up(word): mydictionary = en_dictionary(str(word)) myfanyi = fanyi_dictionary(str(word)) res = translate(mydictionary, myfanyi) return res