【无标题】python实现有道翻译
作者:互联网
'''
import requests
import json
def translate(word=None):
url = 'http://fanyi.youdao.com/translate'
Form_Data = {'action': 'FY_BY_REALTIME', 'i': word, 'from': 'AUTO', 'to': 'AUTO', 'smartresult': 'dict',
'client': 'fanyideskweb', 'salt': '16076755295386', 'sign': '11b6494ac1254a69f4f55bf7b6511c3e',
'lts': '1607675529538', 'bv': '46dc72e3f78c8e58e69300149bb03d64', 'doctype': 'json', 'version': '2.1',
'keyfrom': 'fanyi.web', 'action': 'FY_BY_REALTlME'}
response = requests.post(url, data=Form_Data)
content = json.loads(response.text)
return content['translateResult'][0][0]['tgt']
word = input('请输入要翻译的中文:')
print(translate(word))
标签:word,Form,python,FY,有道,无标题,content,json,translate 来源: https://blog.csdn.net/qq_46017342/article/details/122219763