文档字符串 __doc__

来源:互联网 发布:矩阵lu分解例题3*3 编辑:程序博客网 时间:2024/06/11 11:12
def printMax(x, y):
    '''Prints the maximum of two numbers.


    The two values must be integers.'''
    x = int(x) # convert to integers, if possible
    y = int(y)


    if x > y:
        print x, 'is maximum'
    else:
        print y, 'is maximum'


printMax(3, 5)


  输出为:5 is maximum


printMax(3, 5)

print printMax.__doc__

   输出为:

5 is maximum

Prints the maximum of two numbers.


    The two values must be integers

文档字符串的惯例是一个多行字符串,它的首行以大写字母开始,句号结尾。第二行是空行,从第三行开始是详细的描述。 


    

原创粉丝点击