Error in user YAML: (<unknown>): found a tab character that violate indentation while scanning a plain scalar at line 3 column 3
---
- oeasy Python 0556
- 这是 oeasy 系统化 Python 教程,从基础一步步讲,扎实、完整、不跳步。愿意花时间学,就能真正学会。
- 本教程同步发布在:
- 个人网站: `https://oeasy.org`
- 蓝桥云课: `https://www.lanqiao.cn/courses/3584`
- GitHub: `https://github.com/overmind1980/oeasy-python-tutorial`
- Gitee: `https://gitee.com/overmind1980/oeasypython`
---import requests
def ch_en(txt):
url = f'https://dict.youdao.com/suggest?num=5&ver=3.0&doctype=json&cache=false&le=en&q={txt}'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 SLBrowser/9.0.0.10191 SLBChan/51'
}
resq = requests.get(url, headers=headers)
dic = resq.json()
res = dic["data"]["entries"][0]["explain"]
return res
def ch_de(txt):
url = f'https://dict.youdao.com/suggest?num=5&ver=3.0&doctype=json&cache=false&le=de&q={txt}'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 SLBrowser/9.0.0.10191 SLBChan/51'
}
resq = requests.get(url, headers=headers)
dic = resq.json()
res = dic["data"]["entries"][0]["explain"].split(";")
return res[1].strip()
content = "衣服"
en_res = ch_en(content)
de_res = ch_de(content)
print(en_res)
print(de_res)
- 本文来自 oeasy Python 系统教程。
- 想完整、扎实学 Python,
- 搜索 oeasy 即可。