python基础31[docstring]

 

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
# 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()

    

 

完!

posted @ 2011-03-08 18:33  iTech  阅读(11671)  评论(1编辑  收藏  举报