python3如何看文档

图片[1]-python3如何看文档-uusu优素-乐高,模型,3d打印,编程

调用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
喜欢就支持一下吧
点赞7 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容