# _*_ coding::utf_8 _*_
import urllib.request
import urllib.parse
# 开始url、(word、data在一块)headers请求头
post_url='https://fanyi.baidu.com/sug'
word=input('输入查询单词:')
form_data={
'kw':word,
}
headers={
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36'
}
#对data进行encode()操作,urlencode
form_data=urllib.parse.urlencode(form_data).encode()
# 伪装
url=urllib.request.Request(url=post_url,headers=headers)
#post请求中要加入data值
response=urllib.request.urlopen(url,data=form_data)
#输出post
print(response.read().decode())