#POST请求的数据保存在表单中dict
#利用字典dict = {‘what‘:‘flag‘}可以达到这一要求
from urllib import request,parse
url = "http://123.206.87.240:8002/post/"
headrs = {
‘User-Agent‘:"Mozilla/4.0 (compatible; MSIE 5.5;Windows NT)",
‘Host‘:‘httpbin.org‘
}
dict = {‘what‘:‘flag‘}
data = bytes(parse.urlencode(dict),encoding=‘utf8‘)
req = request.Request(url=url,data=data,headers=headrs,method=‘POST‘)
response = request.urlopen(req)
print(response.read().decode(‘utf-8‘))


Python解决web基础$_POST 30
原文:https://www.cnblogs.com/Osword/p/9820975.html