文档字符串

[root@localhostpython]# cat foo.py

#!/usr/bin/env python

"""foo.py--sample module demonstrating documentation strings"""

class Foo(object):

     """Foo() -empty class ... to bedeveloped"""

def bar(x):

     """bar(x) -function docstring for bar,prints outits arg 'x'"""

     print x

 

[root@localhostpython]# python

Python 2.7.9 (default,Feb 18 2016, 11:31:36)

[GCC 4.4.7 20120313(Red Hat 4.4.7-16)] on linux2

Type "help","copyright", "credits" or "license" for moreinformation.

>>> import foo

>>>foo.__doc__

'foo.py --sample moduledemonstrating documentation strings'

>>>foo.Foo.__doc__

'Foo() -empty class ...to be developed'

>>>foo.bar.__doc__

"bar(x) -functiondocstring for bar,prints out its arg 'x'"

 

 

 

分割线
感谢打赏
江西数库信息技术有限公司
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS