# #post請求百度之詳細翻譯
# import urllib.request
# import urllib.parse
# url = 'https://fanyi.baidu.com/sug'
# data = {
# 'kw': "spide"
# }
# print(data)
# data = urllib.parse.urlencode(data).encode('utf-8')
# print(data)
# headers = {
# 'User-Agent': ' Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
# }
# #定製請求 # post請求的引數,是不會拼接在url的後面的,而是需要放在請求物件定製的引數中
# request = urllib.request.Request(url=url,data=data,headers=headers)
# # 模擬瀏覽器向伺服器傳送請求
# respose = urllib.request.urlopen(request)
# #獲取響應資料
# context = respose.read().decode('utf-8')
# context = context
# print(context)
#
# import json
#
# obj = json.loads(context)
# print(obj)
# post 請求方式的引數必須編碼 data = urllib.parse.urlencode(data).encode('utf-8')
# 編碼之後必須呼叫encode方法
# 引數是放在請求物件定製的方法中,request = urllib.request.Request(url=url, data=data, headers=headers)