One - One Code All

Blog Content

Python通过requests模块发送POST请求

Python   2010-04-17 09:13:13
#!/usr/bin/python
# -*- coding:utf-8 -*-

import requests

"""
通过requests可以向某个地址发送请求
"""

"""
response = requests.get('http://127.0.0.1:8000/asset.html')
# 通过get请求返回的文本值
print(response.text)
"""


# post发送的数据
postData = {
    'username':'Angela',
    'password':'123456',
    'salary':2000,
}

# 对于我们工作中的自己人,我们一般会使用别的验证,而不是csrf_token验证
response = requests.post('http://127.0.0.1:8000/asset.html',data=postData)
# 通过get请求返回的文本值
print(response.text)



上一篇:python日志系统用logging 代替print
下一篇:requests中response.json()方法

The minute you think of giving up, think of the reason why you held on so long.