起因:

想着上学看不懂English的PDF感慨万分........

然后就有了翻译的脚本。

截图:python写一个翻译的小脚本

代码:

#-*- coding:'utf-8' -*-
import requests
import json
import time
start=time.time()
def live():
  while True:
    content=input('输入你要翻译的:')
    if content=="e":
        break
    chrome={"user-agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"}
    url="https://fanyi.youdao.com/openapi.do?keyfrom=123licheng&key=1933182090&type=data&doctype=json&version=1.1&q={}".format(content)
    html=requests.get(url,headers=chrome)
    resqer=html.content
    load=json.loads(resqer)
    print(load["translation"][0])
live()
exit=time.time()
print('[+]该程序耗时',exit-start)

  

相关文章:

  • 2021-12-05
  • 2021-11-30
  • 2021-05-03
  • 2021-12-29
  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
  • 2022-02-26
猜你喜欢
  • 2021-06-12
  • 2021-05-31
  • 2021-10-03
  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
相关资源
相似解决方案