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))
    	
  • 相关阅读:
    drag element
    时间会改变一切
    Windows下MySQL的my.ini文件字符集测试(二)
    Windows下MySQL的my.ini文件字符集测试
    SQL Server和MySQL主外键写法对比
    SQL Server外键约束
    [SQL Server]重命名数据库【转】
    SQL Server 2008 R2链接MySQL 5.6
    空值的日期类型和update 中的null
    删除数据库中所有表
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348355.html
Copyright © 2011-2022 走看看