1、使用requests模块
代码语言:javascript复制import request
url='http://www.xxx.com/xxx'
data={'username':'zhangsan','password':'zhangsanpw'}
r=requests.post(url,data=data)
print r.text
2、使用urllib2模块
代码语言:javascript复制import urllib2
import urllib
url='http://www.xxx.com/xxx'
data={'username':'zhangsan','password':'zhangsanpw'}
r = urllib2.Request(url,urllib.urlencode(data))
result = urllib2.urlopen(req)
print result.read()