import os import urge os.environ["APP_KEY"] = "2402e28def14849b" os.environ["APP_SECRET"] = "r6MzkjgYV5aIVlVosycGi0M7y6czlSCx" sentence = "Hello world again" words = sentence.split() # print(words) for w in words: result = urge.translate(w).once() for m in result: print(m)
import urge import os os.environ["YOUDAO_AI_KEY"] = "2402e28def14849b" os.environ["YOUDAO_AI_SECRET"] = "r6MzkjgYV5aIVlVosycGi0M7y6czlSCx" file_list = os.listdir("./notes") for f in file_list: path = "./notes/" + f if path.endswith(".txt"): content = open(path).read() words = content.split("\n") for w in words: if w: meaning = urge.translate(w).once() print(meaning)
import urge import os os.environ["YOUDAO_AI_KEY"] = "2402e28def14849b" os.environ["YOUDAO_AI_SECRET"] = "r6MzkjgYV5aIVlVosycGi0M7y6czlSCx" word = "hello" meanings = urge.translate(word).once() # print(meanings) for i in meanings: result = word + ' 有 ' + i + ' 的意思' print(result)
import urge import os os.environ["YOUDAO_AI_KEY"] = "2402e28def14849b" os.environ["YOUDAO_AI_SECRET"] = "r6MzkjgYV5aIVlVosycGi0M7y6czlSCx" file = open("./notes/words.txt") result = file.read() print(result) word_list = result.split("\n") print(word_list) for word in word_list: if len(word) > 3: print("---" * 15) print(word) result = urge.translate(word).once() print("---" * 15) print(result)
import urge import os import pprint os.environ["YOUDAO_AI_KEY"] = "2402e28def14849b" os.environ["YOUDAO_AI_SECRET"] = "r6MzkjgYV5aIVlVosycGi0M7y6czlSCx" word = "hello" result = urge.translate(word, full=True).once() # print("单词解释:" + result["simple_translation"]) print("美式音标: " + result["us-phonetic"]) print("详细解释: " + result["web_dict"]) pprint.pprint(result)
import os import urge os.environ["YOUDAO_AI_KEY"] = "2402e28def14849b" os.environ["YOUDAO_AI_SECRET"] = "r6MzkjgYV5aIVlVosycGi0M7y6czlSCx" result = urge.translate("hello").once() print(result)