是否可以使用 python shell 读取 Python 文件 w/o 的文档字符串?
Is it possible to read Doc Strings of a Python file w/o using python shell?
我想知道是否有任何方法可以在导入之前从命令行读取 python 文件中存在的文档字符串,或者 w/o 使用任何 Ipython 或Python 内核,就像 'man' 命令一样。
您可以 execute some python code from the command line,因此给定一个名为 my_module.py
的模块和一个名为 my_function
的函数,如下:
python -c "from my_module import my_function;print my_function.__doc__"
将打印出文档字符串
我想知道是否有任何方法可以在导入之前从命令行读取 python 文件中存在的文档字符串,或者 w/o 使用任何 Ipython 或Python 内核,就像 'man' 命令一样。
您可以 execute some python code from the command line,因此给定一个名为 my_module.py
的模块和一个名为 my_function
的函数,如下:
python -c "from my_module import my_function;print my_function.__doc__"
将打印出文档字符串