使用 python 腳本快速測試 post 請求

因爲 chrome 無法模擬發送 post 請求,因此之前找了一個叫 postman 的工具進行服務端的 post 請求測試,結果出現各種迷之 bug。後來才發現 python 做這種事情簡直不要太爽:

import requests

url = 'http://127.0.0.1:8000'
d = {'op': 'add', 'id': '1', 'text': 'test', 'password': 'xxxxxx'}
r = requests.post(url, data=d)
print(r.text)
print(r.status_code)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章