get方式:
from urllib import parse,request
url='http://localhost/index.php?age=222&uname=111'
re=request.Request(url)
res=request.urlopen(re)
print(res.read())
#其中传入的数据已经可以正常显示在网页中了
post方式:
from urllib import parse,request
values={'uname':'111','age':'222'}
data=parse.urlencode(values)
url='http://localhost/index.php'
req=request.Request(url,data.encode(encoding='utf-8'))
res=request.urlopen(req)
print(res.read())
#其中传入的数据已经可以正常显示在网页中了
post比get更安全
//requests库比urllib库好用