DocString『文档字符串』
在函数的第一个逻辑行的字符串,是这个函数的DocString,它通常是一个多行字符串,它的首行以大写字母开始,句号结尾,第二行是空行,从第三行开始是详细的描述。
使用__doc__(双下划线)调用一个函数的DocString
def printMax (x , y):
'''Print 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)
print printMax.__doc__