Help https://docs.python.org/2/library/functions.html
dir () function
D:\pythontest>python Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AM D64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import requests >>> res = requests.get('https://www.sogou.com/link?url=DSOYnZeCC_popvGkrcLjd__A2 nuyEZQRtN0U1Xf4Goe7gAE91qpuJw..') >>> >>> >>> dir(res) ['__attrs__', '__bool__', '__class__', '__delattr__', '__dict__', '__dir__', '__ doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattribu te__', '__getstate__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', ' __lt__', '__module__', '__ne__', '__new__', '__nonzero__', '__reduce__', '__redu ce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '_ _subclasshook__', '__weakref__', '_content', '_content_consumed', '_next', 'appa rent_encoding', 'close', 'connection', 'content', 'cookies', 'elapsed', 'encodin g', 'headers', 'history', 'is_permanent_redirect', 'is_redirect', 'iter_content' , 'iter_lines', 'json', 'links', 'next', 'ok', 'raise_for_status', 'raw', 'reaso n', 'request', 'status_code', 'text', 'url'] >>> >>> >>> print(res.url) https://www.sogou.com/link?url=DSOYnZeCC_popvGkrcLjd__A2nuyEZQRtN0U1Xf4Goe7gAE91 qpuJw.. >>> print(res.text) <meta content="always" name="referrer"><script>window.location.replace("http://w ww.hujiang.com/ciku/register/")</script><noscript><META http-equiv="refresh" con tent="0;URL='http://www.hujiang.com/ciku/register/'"></noscript>
help () function
Call built-in help system
>>> help(res) Help on Response in module requests.models object: class Response(builtins.object) | The :class:`Response <Response>` object, which contains a | server's response to an HTTP request. | | Methods defined here: | | __bool__(self) | Returns True if :attr:`status_code` is less than 400. | | This attribute checks if the status code of the response is between | 400 and 600 to see if there was a client error or a server error. If | the status code, is between 200 and 400, this will return True. This | is **not** a check to see if the response code is ``200 OK``. | | __enter__(self) | | __exit__(self, *args) | | __getstate__(self) | | __init__(self) | Initialize self. See help(type(self)) for accurate signature. | | | | | | | | | - More -
# press q to exit
vars () function
VARS ( [ object ] ) Returns __dict__ object attributes of the object, wherein the object may be an object modules, classes, instances, or any other objects have __dict__ properties. So, with direct access to the property __dict__ equivalent. Examples are as follows (here anti embodiment, mser __dict__ no object attributes):
>>> vars(res) {'request': <PreparedRequest [GET]>, 'reason': 'OK', 'headers': {'Server': 'ngin x', 'UUID': '6e3340cd-af97-40b4-bc43-f61aef2f27fc', 'Content-Type': 'text/html; charset=GBK', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'Expires': 'Sat, 24 Aug 2019 16:01:02 GMT', 'Content-Encoding': 'gzip', 'Date': 'Sat, 24 Au g 2019 16:01:02 GMT', 'Set-Cookie': 'ABTEST=0|1566662462|v17; expires=Mon, 23-Se p-19 16:01:02 GMT; path=/, IPLOC=CN4601; expires=Sun, 23-Aug-20 16:01:02 GMT; do main=.sogou.com; path=/, SUID=E5FF1D6F2513910A000000005D615F3E; expires=Fri, 19- Aug-2039 16:01:02 GMT; domain=.sogou.com; path=/, black_passportid=1; domain=.so gou.com; path= /; expires = Fri, 01 -Dec- 1994 16 : 00 : 00 GMT " , " Transfer-Encoding " , " c hunked ' , ' P3P ' , ' CP = " care admas Deva PSAo PSDo our bus UNI PUR INT DEM STA PEE Co. 1000 NAV OTC NOI DSP COR, " CP = " care admas Deva PSAo PSDo our bus UNI PUR INT DEM STA PEE COM NAV OTC NOI DSP COR, " CP = " care admas Deva PSAo PSDo our bus UNI PUR Int DEM STA PRE COM NAV OTC NOI DSP COR"', 'Cache-Control': 'max-age=0'}, 'status_co de': 200, '_content_consumed': True, 'history': [], 'elapsed': datetime.timedelt a(0, 0, 669786), '_content': b'<meta content="always" name="referrer"><script>wi ndow.location.replace("http://www.hujiang.com/ciku/register/")</script><noscript ><META http-equiv="refresh" content="0;URL=\'http://www.hujiang.com/ciku/registe r/\'"></noscript>', 'cookies': <RequestsCookieJar[Cookie(version=0, name='IPLOC' , value='CN4601', port=None, port_specified=False, domain='.sogou.com', domain_s pecified=True, domain_initial_dot=True, path='/', path_specified=True, secure=Fa lse, expires=1598198462, discard=False, comment=None, comment_url=None, rest={}, rfc2109=False), Cookie(version=0, name='SUID', value='E5FF1D6F2513910A000000005 D615F3E', port=None, port_specified=False, domain='.sogou.com', domain_specified =True, domain_initial_dot=True, path='/', path_specified=True, secure=False, exp ires=2197382462, discard=False, comment=None, comment_url=None, rest={}, rfc2109 =False), Cookie(version=0, name='ABTEST', value='0|1566662462|v17', port=None, p ort_specified=False, domain='www.sogou.com', domain_specified=False, domain_init ial_dot=False, path='/', path_specified=True, secure=False, expires=1569254462, discard=False, comment=None, comment_url=None, rest={}, rfc2109=False)]>, 'url': 'https://www.sogou.com/link?url=DSOYnZeCC_popvGkrcLjd__A2nuyEZQRtN0U1Xf4Goe7gAE 91qpuJw..', '_next': None, 'encoding': 'GBK', 'raw': <urllib3.response.HTTPRespo nse object at 0x00000000034BE9B0>, 'connection': <requests.adapters.HTTPAdapter object at 0x00000000034AA4A8>} >>>
type () function
of the type ( object ) returns the type of target object.
>>> type(res) <class 'requests.models.Response'>
callable () function
a Callable ( object ): If the object object can be called, then returns True, otherwise False. Note that even though returns True may also call failed, but returns False call must have failed.
>>> callable(res)
False