python __doc__的作用

对于代码功能的注释,通过__doc__输出。

1 """
2 
3 this script does nothing, only to test the use of __doc__
4 
5 """
6 
7 if __name__ == "__main__":
8     print(__doc__)

运行输出  

this function does nothing, only to test the use of __doc__
def test():

"""

this function does nothing, only to test the use of __doc__

"""

pass

test.
__doc__


运行输出  

this function does nothing, only to test the use of __doc__
posted @ 2017-03-10 17:41  张鑫Devin  阅读(1619)  评论(1)    收藏  举报