当前位置: 首页 > 图灵资讯 > 行业资讯> 如何查看python文档

如何查看python文档

发布时间:2025-05-09 10:49:12

调用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

相关推荐:Python入门教程

使用dir可以查看模块或对象的方法。

In[3]:dir(requests)
Out[3]:
['ConnectionError',
'HTTPError',
'compat',
'cookies',
'delete',
'exceptions',
'get',
'head',
'hooks',
...

使用ipython+查看

In[4]:requests.get?
Type:function
Stringform:<functiongetat0x10e6c35f>
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

相关文章

python3兼容python2吗

python3兼容python2吗

2025-05-09
python3 whl怎么安装

python3 whl怎么安装

2025-05-09
python 字典怎么提取value

python 字典怎么提取value

2025-05-09
python 怎样计算字符串的长度

python 怎样计算字符串的长度

2025-05-09
python 怎么样反向输出字符串

python 怎么样反向输出字符串

2025-05-09
python 怎么判断字符串开头

python 怎么判断字符串开头

2025-05-09