函数的文档

def spherical_harmonic_fitter(grid, order):
    "求球谐函数拟合的系数"

    # 具体实现省略
    pass

help(spherical_harmonic_fitter)
  • 通过help(function_name)读取函数文档
Help on function spherical_harmonic_fitter in module __main__:

spherical_harmonic_fitter(grid, order)
    求球谐函数拟合的系数
  • 同理在类与对象的定义中也有类似的文档字符串的用法。
  • 更多的注释:使用三引号
def function_name(parameter_list):
    """
    中间是一大串文档,可以使用单个"
    """
    # 函数实现代码
    pass