Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何访问程序´;从命令行删除docstring?_Python_Python 3.x_Command Line_Module_Python Import - Fatal编程技术网

Python 如何访问程序´;从命令行删除docstring?

Python 如何访问程序´;从命令行删除docstring?,python,python-3.x,command-line,module,python-import,Python,Python 3.x,Command Line,Module,Python Import,我有一个python“hangman”程序,可以让你在控制台中玩hangman。该程序中的函数具有文档字符串,用于记录它们的操作。我想运行命令行指令来访问那些docstring。比如: python help(hangman.py) 然后得到类似于 my_function() Counts how many rings lebron lost ... 我不知道如何使hangman.py文件作为一个模块工作(它也不允许我将其导入其他程序)。 如果有人知道我是如何实现这些目标的,我将不胜

我有一个python“hangman”程序,可以让你在控制台中玩hangman。该程序中的函数具有文档字符串,用于记录它们的操作。我想运行命令行指令来访问那些docstring。比如:

python help(hangman.py)
然后得到类似于

my_function()
    Counts how many rings lebron lost
...
我不知道如何使hangman.py文件作为一个模块工作(它也不允许我将其导入其他程序)。
如果有人知道我是如何实现这些目标的,我将不胜感激。

你能分享一下代码的组织方式吗?您可以迭代该方法并显示每个docTry
pydoc hangman.my_函数
pydoc3 hangman.my_函数
。pydoc通常是python发行版的一部分。
hangman.py
是一个模块,如果它与导入它的顶级脚本位于同一目录中(或者如果python shell具有当前工作目录)。您还可以将其目录添加到
PYTHONPATH
。但最后,您需要知道如何安装模块。