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

Python Essay Document Strings (DocStrings)

巴扎黑
Release: 2016-12-03 11:29:40
Original
1260 people have browsed it

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__
Copy after login


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template