调用help函数,可以看到一个函数或者方法的字符串文档。
In[1]:importrequests In[2]:help(requests.get) Helponfunctiongetinmodulerequests.api: get(url,params=None,**kwargs) SendsaGETrequest. :paramurl:URLforthenew:class:`Request`object. :paramparams:(optional)Dictionaryorbytestobesentinthequerystringforthe:class:`Request`. :param\*\*kwargs:Optionalargumentsthat``request``takes. :return::class:`Response<Response>`object :rtype:requests.Response
使用dir可以查看模块或对象都有那些方法。
In[3]:dir(requests) Out[3]: ['ConnectionError', 'HTTPError', 'compat', 'cookies', 'delete', 'exceptions', 'get', 'head', 'hooks', ...
使用ipython+?查看
In[4]:requests.get? Type:function Stringform:<functiongetat0x10e6c35f0> File:/Library/Python/2.7/site-packages/requests/api.py Definition:requests.get(url,params=None,**kwargs) Docstring: SendsaGETrequest. :paramurl:URLforthenew:class:`Request`object. :paramparams:(optional)Dictionaryorbytestobesentinthequerystringforthe:class:`Request`. :param\*\*kwargs:Optionalargumentsthat``request``takes. :return::class:`Response<Response>`object :rtype:requests.Response
使用pydoc查看字符串文档
~python-mpydocrequests Helponpackagerequests: NAME requests FILE /Library/Python/2.7/site-packages/requests/__init__.py DESCRIPTION requestsHTTPlibrary RequestsisanHTTPlibrary,writteninPython,forhumanbeings.BasicGET usage: >>>importrequests >>>r=requests.get('https://www.python.org') >>>r.status_code 200 >>>'Pythonisaprogramminglanguage'inr.content True原文来自:https://www.py.cn
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容