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
原文地址:https://www.cnblogs.com/liujiaxin2018/p/14502799.html