import urllib.request import json while True: txt=input('请输入需要翻译的语句(自动识别语言)') r = urllib.request.urlopen('https://fanyi.youdao.com/translate?&doctype=json&type=AUTO&i='+urllib.parse.quote(txt)) state=json.loads(r.read()) print(state['translateResult'][0][0]['tgt'])