python中如何获取函数文档

 

1、

>>> def a(x,y):
    """
function: sum
author: xxxx
date: 2021:03:08
"""
    print(x +  y)

    
>>> a(10,8)
18
>>> print(a.__doc__)     ## 获取函数文档

function: sum
author: xxxx
date: 2021:03:08

>>> help(a)             ## 获取帮助
Help on function a in module __main__:

a(x, y)
    function: sum
    author: xxxx
    date: 2021:03:08

 

posted @ 2021-03-08 22:39  小鲨鱼2018  阅读(240)  评论(0编辑  收藏  举报