Python:文档字符串之DocStrings

相当于JavaDoc。函数语句块第一行开始,第二行是空行(惯例)。
可以用函数名.__doc__获取,help内置函数会获取并展示。

def f():
    '''Thid is function f.

    this is describes.'''
    pass

print f.__doc__
help(f)

#输出
Thid is function f.

    this is describes.
Help on function f in module __main__:

f()
    Thid is function f.

    this is describes.
posted @ 2018-12-25 09:32  xuejianbest  阅读(196)  评论(0编辑  收藏  举报