【发布时间】:2010-11-10 21:30:46
【问题描述】:
好的,我有一个时刻让我怀疑自己使用电脑的能力。这不是我想在我的第一个 SO 帖子中提出的那种问题,但这里是这样。
开始学习 Zed 的新书“Learn Python the Hard Way”,因为我在中断了 10 年之后一直希望重新开始编程,而 python 一直是我想要的。这本书真的和我说话了。话虽如此,我在命令中遇到了一个严重的 pydoc 问题。我的系统路径中有 c:/python26 中的所有目录,无论 pwd 如何,我都可以从命令行执行 pydoc,但它不接受任何参数。不管我输入什么,我都会得到标准的 pydoc 输出,告诉我可接受的参数。
有什么想法吗?无论如何,我按照 Zed 的建议安装了 ActivePython。
C:\Users\Chevee>pydoc file
pydoc - the Python documentation tool
pydoc.py <name> ...
Show text documentation on something. <name> may be the name of a
Python keyword, topic, function, module, or package, or a dotted
reference to a class or function within a module or module in a
package. If <name> contains a '\', it is used as the path to a
Python source file to document. If name is 'keywords', 'topics',
or 'modules', a listing of these things is displayed.
pydoc.py -k <keyword>
Search for a keyword in the synopsis lines of all available modules.
pydoc.py -p <port>
Start an HTTP server on the given port on the local machine.
pydoc.py -g
Pop up a graphical interface for finding and serving documentation.
pydoc.py -w <name> ...
Write out the HTML documentation for a module to a file in the current
directory. If <name> contains a '\', it is treated as a filename; if
it names a directory, documentation is written for all the contents.
C:\Users\Chevee>
编辑:新信息,pydoc 在 PowerShell 中运行良好。作为一个 linux 用户,我不知道为什么要尝试使用 cmd ——但我仍然很想弄清楚 pydoc 和 cmd 是怎么回事。
编辑 2:更多新信息。在cmd中...
c:\>python c:/python26/lib/pydoc.py file
...工作得很好。只需在 PowerShell 中使用 pydoc,一切都可以正常工作,而无需我担心 pwd、扩展名或路径。
【问题讨论】:
-
显示一个指示问题的示例控制台会话,最好是从 cmd 窗口复制/粘贴的会话。 (编辑您的帖子,不要添加答案或评论)。此外,在编辑窗口中选择文本后使用 10101010 按钮将其格式化为代码。
-
如果以
pydoc.py ...而不是pydoc ...输入命令会发生什么? -
@Jim Garrison - 相同的输出。我将 for.py 的文件关联设置为 python.exe,因此我不必键入扩展名。这可能是我的问题吗?
-
@Jim 这几乎肯定是你的问题。我不认为您可以从 Windows 上的命令行运行这样的脚本。虽然不是积极的。