Pydoc没有看到docstrings?

Ski*_*man 6 python pydoc

显然我在这里缺少一些严肃的东西.这是我的测试程序:

"""
Doc and nothing but doc
"""

class TestMe(object):
    """
    class documentation goes here
    """
    def testFunc(self):
        """
        FunctionDoc Goes here
        """
        print "Hello world"

if __name__ =="__main__":
    t=TestMe()
    t.testFunc()
Run Code Online (Sandbox Code Playgroud)

我运行它并打印出"Hello world",natch.但是pydoc.py test.py给出这个:

no Python documentation found for 'test.py'
Run Code Online (Sandbox Code Playgroud)

显然我在这里缺少一些简单的东西,但是什么呢?

--edit-- Per Vishnu的建议我print t.__doc__在文件的最后一行添加了" ",现在运行该文件给出了:

Hello world

    class documentation goes here
Run Code Online (Sandbox Code Playgroud)

但是pydoc仍然没有找到任何文档.

Ned*_*der 20

Pydoc需要模块名称,而不是文件名.试试pydoc test.

如果参数中包含斜杠,它将使用参数作为文件名: pydoc ./test.py