Home  >  Article  >  Backend Development  >  Python Essay Document Strings (DocStrings)

Python Essay Document Strings (DocStrings)

巴扎黑
巴扎黑Original
2016-12-03 11:29:401169browse

There is a wonderful feature in Python, documentation strings, also known as DocStrings. It can be used to add descriptive text to our modules, classes, and functions, making the program easy to read and understand. More importantly, these descriptive text information can be output through Python's own standard methods. Here are some examples.

'''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__


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn