1、首先DocString可以说相当于函数里的一个注释。
2、写法
def hello():
''' This is hello function.
It will be print hello world.'''
print 'hello world'
hello()
print hello.__doc__
DocStrings 就是函数里三引号中的部分,用于注释函数,可以通过.__doc__调出函数中的这部分注释。
以上代码输出结果:
hello world
This is hello function
It will be print hello world
3、注意事项
DocStrings 首字母大写,第一行后空一行,从第三行开始是正式内容。