zoukankan      html  css  js  c++  java
  • 3.在url中传递参数(其实与requests模块使用大致相同)

    3.在url中传递参数(其实与requests模块使用大致相同)
    
    node2:/root/python/20200525#cat t500.py 
    import asyncio,aiohttp
    
    async def fetch_async(url,params):
        async with aiohttp.ClientSession() as session:
            async with session.get(url,params=params) as r:
                print(dir(r))
                print(r.url)
                print(await r.text())
    data1={'a': '111', 'b': '111'}
    data2={'a': '222', 'b': '222'}
    data3={'a': '333', 'b': '333'}
    tasks = [fetch_async('http://192.168.137.3:9000/test111/',data1), fetch_async('http://192.168.137.3:9000/test222/',data2),fetch_async('http://192.168.137.3:9000/test333/',data3)]
    
    event_loop = asyncio.get_event_loop()
    results = event_loop.run_until_complete(asyncio.gather(*tasks))
    event_loop.close()
    
    #@require_http_methods(["POST"])
    def test111(req):
        time.sleep(5)
        a=req.GET['a']
        b=req.GET['b']
        print a
        print b
        return HttpResponse(str(a))
    #@require_http_methods(["POST"])
    def test222(req):
        time.sleep(6)
        a=req.GET['a']
        print a
        b=req.GET['b']
        print b
        return HttpResponse(str(a))
    #@require_http_methods(["POST"])
    def test333(req):
        time.sleep(7)
        a=req.GET['a']
        print a
        return HttpResponse(str(a))
    #@require_http_methods(["POST"])
    def test444(req):
        time.sleep(8)
        a=req.GET['a']
        print a
        return HttpResponse(str(a))
    	
  • 相关阅读:
    Wannafly Winter Camp 2020 Day 7D 方阵的行列式
    [CF1311F] Moving Points
    [CF1311E] Construct the Binary Tree
    [CF1311D] Three Integers
    [CF1311C] Perform the Combo
    [CF1311B] WeirdSort
    [CF1311A] Add Odd or Subtract Even
    Wannafly Winter Camp 2020 Day 7A 序列
    SP7258 SUBLEX
    Wannafly Winter Camp 2020 Day 6J K重排列
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348355.html
Copyright © 2011-2022 走看看