优秀的编程知识分享平台

网站首页 > 技术文章 正文

24.函数说明文档(excel函数说明文档)

nanyue 2024-10-01 13:07:25 技术文章 8 ℃

函数说明文档,顾名思义就是一个对函数说明的信息文档

格式如下:

def 函数名():
    """
    用3对双引号进行包裹,这里就是函数的说明文档,用来对函数的功能,使用方式等进行说明
    以便开发人员能够快速的了解此函数
    """
    pass

函数文档对于我们的意义:

Python内置了很多的函数,但这些函数具体的功能不是我们编写的,我们很难在较短的时间内读懂函数的实现代码

但是只要有了函数说明文档,我们就能快速的知道这个函数的作用,能够大大提高可读性

那怎样用函数的说明文档呢?

Help on built-in function print in module builtins:

print(...)
    print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
    
    Prints the values to a stream, or to sys.stdout by default.
    Optional keyword arguments:
    file:  a file-like object (stream); defaults to the current sys.stdout.
    sep:   string inserted between values, default a space.
    end:   string appended after the last value, default a newline.
    flush: whether to forcibly flush the stream.

给大家的建议:

编写的代码不仅仅是自己看,还有可能是同事看、同学看、领导看等

当我们的代码中有函数,虽然函数说明文档可写可不写,但是建议大家写上,这样会更加规范

最近发表
标签列表