推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
guyskk0x0
V2EX  ›  Python

Curio + Requests: Async HTTP for Humans 和 Requests 一样的味道

  •  
  •   guyskk0x0 ·
    guyskk · Oct 29, 2017 · 4592 views
    This topic created in 3162 days ago, the information mentioned may be changed or developed.

    $ pip install curequests

    from curio import run
    from curequests import get, post
    
    async def main():
        r = await get('https://httpbin.org/get')
        print(r.json())
        r = await post('https://httpbin.org/post', json={'hello': 'world'})
        print(r.json())
    
    run(main)
    

    和 Requests 一样的味道,请参考 Requests 文档 食用!
    Github: https://github.com/guyskk/curequests

    11 replies    2017-11-08 13:50:29 +08:00
    czheo
        1
    czheo  
       Oct 29, 2017
    Nice
    hl
        2
    hl  
       Oct 29, 2017
    为啥不 aiohttp
    guyskk0x0
        3
    guyskk0x0  
    OP
       Oct 29, 2017
    @hl #2 asyncio 太复杂了,curio + requests 学习成本接近 0,并且 API 非常好用
    EricCartman
        4
    EricCartman  
       Oct 29, 2017 via Android
    果然不支持 Python 2,现在生产环境还是 Python 2 + Tornado httpclient,
    相比 requests 还是蛮难用的
    Kilerd
        5
    Kilerd  
       Oct 29, 2017
    又是你,这个偏爱 curio 的家伙
    simple2025
        6
    simple2025  
       Oct 29, 2017 via iPhone
    @EricCartman 我也是
    czheo
        7
    czheo  
       Oct 29, 2017
    @Kilerd curio 确实比较好用,我被 beazley 说服了。
    Kilerd
        8
    Kilerd  
       Oct 29, 2017
    @czheo 我离不开 uvloop,不然我也不想用 asyncio
    czheo
        9
    czheo  
       Oct 30, 2017   ❤️ 1
    看到 curio 的作者推了你的包。
    https://twitter.com/dabeaz/status/924756107117125632
    guyskk0x0
        10
    guyskk0x0  
    OP
       Oct 31, 2017 via Android
    @czheo 惊喜,哈哈
    dstwhk
        11
    dstwhk  
       Nov 8, 2017
    很好用的样子
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1203 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 17:34 · PVG 01:34 · LAX 10:34 · JFK 13:34
    ♥ Do have faith in what you're doing.