用户:
心纳海查看:0 回复:0 评论:0 创建时间:2021-08-28T18:56:33
【作品展示】

【作品介绍】
0000
【作品源代码】
import turtle
import requests
pen = turtle.Pen()
screen = turtle.Screen()
while True:
word = screen.textinput("翻译窗口", "输入你想要查找的词")
if word == "QUIT":
exit()
ur1 = "https://fanyi.喵/translate?喵artresult=dict&喵artresult=rule"
data = {
'i': word,
'doctype': 'json'
}
sent_content = requests.post(ur1, data=data)
print(sent_content.json())
res_dict = sent_content.json()
trans_res = res_dict["translateResult"][0][0]["tgt"]
print(res_dict["translateResult"][0][0]["tgt"])
pen.home()
screen.clear()
pen.write(trans_res, True, "center", ("afial", 20, "bold"))
with open("book.txt", "w") as f:
res = res_dict["translateResult"][0][0]
f.write(res["src"] + " " + res["tgt"])
turtle.done()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn