谷歌翻译api小尝试

代码:

import requests
# 翻译英文为中文
urlbefore='http://translate.google.cn/translate_a/single?client=gtx' \
          '&sl=en&tl=zh-CN'
# urlbefore2='&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&q='
urlbefore2='&dt=md&dt=rm&dt=t&q='
word='dog'
url = urlbefore+urlbefore2+word
r = requests.get(url)
t=r.json()
print(t[0])
print(t[-1])

你可能感兴趣的:(python)