Python之__doc__

简述

__doc__方法是python内置方法之一,该方法通常会输入指定对象中的注释部分

实例

one

def test():
    '''Hollo World'''
    print("phac123")

print(test.__doc__)

输出:

Hollo World

可以看到注释的部分被输出了出来.

two

def test():
    '''Hello World'''

    # sddsfdsfsd
    print("phac123")

    # sdfsdfsdf

    '''sdfsdfsdfasdfdsfasd'''

print(test.__doc__)

输出:

Hello World

可以看到只输出了test方法中的第一行注释.

你可能感兴趣的:(Python)