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

 

posted @ 2021-03-04 10:26  小鲨鱼2018  阅读(184)  评论(0编辑  收藏  举报