docstring:
docstring表示源代码的注释,可以被help()函数识别。
以''' axxxx'''的形式存在,可以为多行。
可以给module,class,function增加docstring。
但是docstring必须在所有的内容的最前面,例如如果给module增加docstring,该docstring必须位于文件的最前面。
实例:
'''
# prerequisite:
# based on Python 2.x
# need Python XXX module
# make XXXXX command is in PATH
# usage:
1) change the variables:XXX,XXX
2) thisscript.py arg1 arg2 arg3
# process:
1) step1
2) step2
3) step3
4) step4
5) step5
# know issues:
1) issue1
2) issue2
# prerequisite:
# based on Python 2.x
# need Python XXX module
# make XXXXX command is in PATH
# usage:
1) change the variables:XXX,XXX
2) thisscript.py arg1 arg2 arg3
# process:
1) step1
2) step2
3) step3
4) step4
5) step5
# know issues:
1) issue1
2) issue2
# Other
Any issues or improvements please contact xxx@126.com
'''
import sys
def loop(): pass
if __name__ == ' __main__ ' :
print len(sys.argv)
for i in sys.argv:
print i
if not len(sys.argv) == 4 :
print __doc__
else :
loop()
'''
import sys
def loop(): pass
if __name__ == ' __main__ ' :
print len(sys.argv)
for i in sys.argv:
print i
if not len(sys.argv) == 4 :
print __doc__
else :
loop()
完!
本文详细介绍了Python中docstring的概念及其使用方法。docstring是一种特殊的注释形式,可以帮助开发者更好地理解模块、类或函数的功能。文章通过具体示例展示了如何为不同的Python组件添加docstring,并解释了它们的作用。
3231

被折叠的 条评论
为什么被折叠?



