python在线翻译脚本_python写一个翻译的小脚本
起因:
想著上學(xué)看不懂English的PDF感慨萬(wàn)分........
然后就有了翻譯的腳本。
截圖:
代碼:
#-*- 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('[+]該程序耗時(shí)',exit-start)
總結(jié)
以上是生活随笔為你收集整理的python在线翻译脚本_python写一个翻译的小脚本的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 蟑螂最怕什么?
- 下一篇: 豌豆种子分别放在两个铺好湿纸巾的杯中,其