码迷,mamicode.com
首页 > 编程语言 > 详细

接口_requests_基于python

时间:2017-10-05 18:02:19      阅读:272      评论:0      收藏:0      [点我收藏+]

标签:ice   requests   style   options   apach   head   install   使用   pat   

HTTP request python官方文档:http://cn.python-requests.org/zh_CN/latest/

基于环境,需要安装requests 模块,安装方法 pip install requests
想学习requests,就通过help吧

import requests
help(requests)

返回结果如下:

C:\Python27\python.exe E:/test/interface/g_3.py
Help on package requests:

NAME
    requests

FILE
    c:\python27\lib\site-packages\requests\__init__.py

DESCRIPTION
    Requests HTTP Library
    ~~~~~~~~~~~~~~~~~~~~~
    
    Requests is an HTTP library, written in Python, for human beings. Basic GET
    usage:
    
       >>> import requests
       >>> r = requests.get(https://www.python.org)
       >>> r.status_code
       200
       >>> Python is a programming language in r.content
       True
    
    ... or POST:
    
       >>> payload = dict(key1=value1, key2=value2)
       >>> r = requests.post(http://httpbin.org/post, data=payload)
       >>> print(r.text)
       {
         ...
         "form": {
           "key2": "value2",
           "key1": "value1"
         },
         ...
       }
    
    The other HTTP methods are supported - see `requests.api`. Full documentation
    is at <http://python-requests.org>.
    
    :copyright: (c) 2017 by Kenneth Reitz.
    :license: Apache 2.0, see LICENSE for more details.

PACKAGE CONTENTS
    __version__
    _internal_utils
    adapters
    api
    auth
    certs
    compat
    cookies
    exceptions
    help
    hooks
    models
    packages
    sessions
    status_codes
    structures
    utils

FUNCTIONS
    check_compatibility(urllib3_version, chardet_version)

DATA
    __author__ = Kenneth Reitz
    __author_email__ = me@kennethreitz.org
    __build__ = 137220
    __cake__ = u\u2728 \U0001f370 \u2728
    __copyright__ = Copyright 2017 Kenneth Reitz
    __description__ = Python HTTP for Humans.
    __license__ = Apache 2.0
    __title__ = requests
    __url__ = http://python-requests.org
    __version__ = 2.18.4
    codes = <lookup status_codes>

VERSION
    2.18.4

AUTHOR
    Kenneth Reitz



Process finished with exit code 0

获取requests所有的方法和类,就使用dir吧

import requests
print dir(requests)

返回如下:

[ConnectTimeout, ConnectionError, DependencyWarning, FileModeWarning, HTTPError, NullHandler, PreparedRequest, ReadTimeout, Request, RequestException, RequestsDependencyWarning, Response, Session, Timeout, TooManyRedirects, URLRequired, __author__, __author_email__, __build__, __builtins__, __cake__, __copyright__, __description__, __doc__, __file__, __license__, __name__, __package__, __path__, __title__, __url__, __version__, _internal_utils, adapters, api, auth, certs, chardet, check_compatibility, codes, compat, cookies, delete, exceptions, get, head, hooks, logging, models, options, packages, patch, post, put, request, session, sessions, status_codes, structures, urllib3, utils, warnings]

 

接口_requests_基于python

标签:ice   requests   style   options   apach   head   install   使用   pat   

原文地址:http://www.cnblogs.com/VseYoung/p/requests.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!