django get請求獲取請求參數

get請求參數:
#@require_http_methods(["POST"])
def test111(req):
    #time.sleep(5)
    a=req.GET['a']
    print a
    b=req.GET['b']
    print b
    return HttpResponse(str(a))
	

# !/usr/bin/env python
# -*- coding: utf-8 -*-

import requests
import os
import time
myurl='http://192.168.137.3:9000/test111/'
print  myurl
s=requests.session()
data={'a':'1111','b':'222'}
#res = requests.post(myurl, data=data)
res = requests.get(myurl, params=data)

print(res.text)



	


April 18, 2020 - 00:34:05
Django version 1.11.9, using settings 'mysite.settings'
Starting development server at http://0.0.0.0:9000/
Quit the server with CONTROL-C.
1111
222
[18/Apr/2020 00:34:08] "GET /test111/?a=1111&b=222 HTTP/1.1" 200 4

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章