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__

 

posted @ 2018-01-17 14:35  sky20080101  阅读(157)  评论(0)    收藏  举报