V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
Livid
V2EX  ›  Python

unirest-python

  •  1
     
  •   Livid · 2015-02-05 04:53:50 +08:00 · 3539 次点击
    这是一个创建于 3373 天前的主题,其中的信息可能已经有所发展或是发生改变。

    来自 Mashape 团队的一个轻量级的 HTTP 库,实现了一个很简洁的异步接口。

    http://unirest.io/python.html

    def callback_function(response):
      response.code # The HTTP status code
      response.headers # The HTTP headers
      response.body # The parsed response
      response.raw_body # The unparsed response
    
    thread = unirest.post("http://httpbin.org/post",
                           headers={ "Accept": "application/json" },
                           params={ "parameter": 23, "foo": "bar" },
                           callback=callback_function)
    
    6 条回复    2015-02-05 10:07:33 +08:00
    xiaket
        1
    xiaket  
       2015-02-05 08:18:59 +08:00
    API好干净
    caizixian
        2
    caizixian  
       2015-02-05 08:31:57 +08:00
    看起来很不错啊
    CosWind
        3
    CosWind  
       2015-02-05 09:04:21 +08:00
    赞一个
    clino
        4
    clino  
       2015-02-05 09:09:35 +08:00
    用callback多了还是感觉会比较虐心
    sujin190
        5
    sujin190  
       2015-02-05 09:44:18 +08:00
    开新线程做callback。。
    ipconfiger
        6
    ipconfiger  
       2015-02-05 10:07:33 +08:00
    callback会传染的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2163 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 01:55 · PVG 09:55 · LAX 18:55 · JFK 21:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.