`
禹爸爸
  • 浏览: 80056 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

Python随笔之文档字符串(DocStrings)

阅读更多

在Python中有一个奇妙的特性,文档字符串,又称为DocStrings。用它可以为我们的模块,类,函数添加说明性的文字,使程序易读易懂,更重要的是可以通过Python自带的标准方法将这些描述性文字信息输出。下面举例说明。

 

'''This is My own Module

Date:2011-09-07
Author:Chris Mao

This is description information'''

class TestClass:
    '''This is TestClass' DocStrings'''
    def func1():
        '''this is func1's DocStrings'''
        pass

def func2():
    '''this is func2'''
    print "this is func2"

print func2.__doc__

 

版权声明:本文为博主原创文章,未经博主允许不得转载。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics