Os:windows 10 Chinese version, python:3.6.4
The document string (docstring) in Python appears in the first row of modules, functions, classes , and is used to describe these programs. It is ignored at execution time, but will
is stored in the __doc__ property of the module, function, and class by the compiler. However, not every module, function, class has a document string.
Part 1. Document strings for custom modules, functions, classes
New module dstest.py, stored in the Python installation directory (can be found when the import module);
Import Dstest, see the module dstest and its function Docfunc, class Docclass document string;
The Help () function is used to get the helper information for modules, functions, and classes that contain the respective document string information, and below to see how to use the
What information does the Help () function get-more information.
-Get Help for module Dstest--it contains the help information for the following function and class
-Get help information for a function
-Get information about a class
Part 2. Document string survey of built-in modules, functions, classes
Take module SYS as an example.
1. Direct access to __doc__ information
It's messy, can't see! Because it is the command line of the Windows platform? \ nto not be parsed into a carriage return!
2. Print __doc__ information using the print function
Parse the \ n as the carriage return character, more neat than the direct output __doc__.
3. Use the Help (SYS) function for assistance information
The best visual help information, should use this!
Take Django as an example to demonstrate a module with no docstring: author-ben.z
The content returned with __doc__ is empty (None), but help can be obtained by helping (Django).
Reference Links:
Python 3.6.5 documentation (there are all the Python files you need and you can choose the Python version)
3 ways to get help with Python
Python Basics (2): __doc__, document String docstring, Help ()