print printMax.__doc__ 函数的第一个逻辑行的字符串是这个函数的 文档字符串
在函数的第一个逻辑行的字符串是这个函数的 文档字符串 。注意,DocStrings也适用于模块和类,我们会在后面相应的章节学习它们。
# -*- coding:gb2312 -*- import subprocess import sys #subprocess.call("pause",shell=True) #subprocess.call("cls",shell=True) #sys.exit(0) #!/usr/bin/python # Filename: func_doc.py 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) print printMax.__doc__

 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号