Python DocString特性
#!/usr/bin/python#Filename:func_doc.pydef printMax(x,y):'''Prints the maximum of two numbersthe two valuse must be integers'''x = int(x)y = int(y)if(x > y):print x,'is maximum'els
·
#!/usr/bin/python
#Filename:func_doc.py
def printMax(x,y):
'''Prints the maximum of two numbers
the two valuse must be integers'''
x = int(x)
y = int(y)
if(x > y):
print x,'is maximum'
else:
print y,'is maximum'
printMax(3,5)
print printMax.__doc__
在函数的第一个逻辑行的字符串是这个函数的 文档字符串 。注意,DocStrings也适用于模块和
类,我们会在后面相应的章节学习它们。
更多推荐



所有评论(0)