相关疑难解决方法(0)

如何使用参数记录方法?

如何使用Python的文档字符串记录带参数的方法?

编辑: PEP 257给出了这个例子:

def complex(real=0.0, imag=0.0):
    """Form a complex number.

    Keyword arguments:
    real -- the real part (default 0.0)
    imag -- the imaginary part (default 0.0)

    """
    if imag == 0.0 and real == 0.0: return complex_zero
    ...
Run Code Online (Sandbox Code Playgroud)

这是大多数Python开发人员使用的约定吗?

Keyword arguments:
<parameter name> -- Definition (default value if any)
Run Code Online (Sandbox Code Playgroud)

我期待一些更正式的东西,比如

def complex(real=0.0, imag=0.0):
    """Form a complex number.

    @param: real The real part (default 0.0)
    @param: imag The imaginary part (default 0.0)

    """
    if imag == 0.0 and real …
Run Code Online (Sandbox Code Playgroud)

python documentation documentation-generation

125
推荐指数
6
解决办法
10万
查看次数

如何使用Pydoc创建文档?

我正在尝试从我的模块中创建一个文档.我pydoc在Windows 7中使用Python 3.2.3从命令行使用:

python "<path_to_pydoc_>\pydoc.py" -w myModule
Run Code Online (Sandbox Code Playgroud)

这导致我的shell充满了文本,我的模块中的每个文件都有一行,说:

no Python documentation found for '<file_name>'
Run Code Online (Sandbox Code Playgroud)

这就像Pydoc试图获取我的文件的文档,但我想自动创建它.我找不到使用谷歌的好教程.有没有人有关于如何使用Pydoc的任何提示?

如果我尝试使用一个文件创建文档

python ... -w myModule\myFile.py
Run Code Online (Sandbox Code Playgroud)

此外,它在我的计算机上有一个指向文件本身的链接,我可以单击它,它会在我的网络浏览器上显示文件内部的内容.

python documentation documentation-generation pydoc python-3.x

60
推荐指数
3
解决办法
12万
查看次数