使用ipython显示python模块位置及模块说明文档

469 阅读1分钟

本人文章<=>个人笔记,若有误,望指正,感激不尽.

本人邮箱:silenceandsharp@163.com

使用ipython导入模块,

  • 输入"模块名"+"回车"可以显示模块包的位置,

  • 输入"模块名"+"?"+"回车"可以显示模块包的位置和模块的说明文档.

以下是命令行操作:

#内置模块
>ipython
In[2]: import sys
In[3]: sys
Out[3]: <module 'sys' (built-in)>
In[4]: sys?
Out[4]: Type:        module
String form: <module 'sys' (built-in)>
Docstring:  
This module provides access to some objects used or maintained by the
interpreter and to functions that interact strongly with the interpreter.

#引用模块
import requests
requests
Out[3]: <module 'requests' from 'C:\\Users\\86185\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\requests\\__init__.py'>
requests?
Type:        module
String form: <module 'requests' from 'C:\\Users\\86185\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\requests\\__init__.py'>
File:        c:\users\86185\appdata\local\programs\python\python36\lib\site-packages\requests\__init__.py
Docstring:  
Requests HTTP library
~~~~~~~~~~~~~~~~~~~~~
Requests is an HTTP library, written in Python, for human beings.