推荐学习书目
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
JhOOOn
V2EX  ›  Python

如果需要在程序中调用 restful API,使用 requests 是否是正确的方式?

  •  
  •   JhOOOn · Apr 3, 2016 · 4955 views
    This topic created in 3716 days ago, the information mentioned may be changed or developed.

    比如,编写一个程序,需要用到某个网站提供的 api , 直接在程序中使用 requests 进行 GET 或者 POST获取或传送相关数据, 这种方式是否正确?

    看过别的2个调用api的程序,一个是用python自带的包urllib实现的,还有使用 httplib的,请问哪种是比较正确的方式,可以给个 比较好的 示例吗?谢谢

    5 replies    2016-04-03 14:10:41 +08:00
    lxrmido
        1
    lxrmido  
       Apr 3, 2016   ❤️ 1
    方式没问题,发帖注意一下全角字符
    murmur
        2
    murmur  
       Apr 3, 2016
    restful 只是一种风格,并没有什么技术上的特别之处,照着 api 上的要求就可以了
    gamexg
        3
    gamexg  
       Apr 3, 2016 via Android
    更好的方法是找现成的库。😀
    pynix
        4
    pynix  
       Apr 3, 2016
    找现成的 rest client ,可能对认证, JSON 转换方面考虑得比较周全。如果不介意的话,从 socket 开始写一个也没有问题的。
    jint
        5
    jint  
       Apr 3, 2016 via iPhone
    @gamexg @pynix 可否推荐一二
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1045 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 18:41 · PVG 02:41 · LAX 11:41 · JFK 14:41
    ♥ Do have faith in what you're doing.