python中函数文档

1、

>>> def a(x,y):       ## 函数文档
    """
    function: sum
    author: xxxx
    date: 2021.3.4
    """
    print(x + y)

    
>>> a(40,80)
120
>>> print(a.__doc__)   ## 获取函数文档

    function: sum
    author: xxxx
    date: 2021.3.4
    
>>> help(a)            ## 获取函数帮助
Help on function a in module __main__:

a(x, y)
    function: sum
    author: xxxx
    date: 2021.3.4
原文地址:https://www.cnblogs.com/liujiaxin2018/p/14478758.html