angrykola

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

文档

#注释  文件中的文档
dir函数 对象中可用属性的列表
文档字符串:__doc__ 附加在对象上的文件中的文档
PyDoc:help函数 对象的呼叫帮助
PyDoc:HTML报表 浏览器总的模块文档
标准手册 正式的语言和库的说明
网站资源 在线教程、例子等
出版的书籍 商业参考书籍

 

 

 

 

 

 

文档字符串:__doc__ 

文档字符串这类注释是写成字符串放在模块文件、函数一级类语句的顶端,就在任何可执行程序代码前(#注释在其之前也没问题)。python会自动封装这个字符串,也就是成为所谓的文档字符串,使其成为相应对象的__doc__属性。

>>> def fuc():
    #**************
    "this is __doc__:文档字符串"
    print("doc")    
>>> fuc.__doc__
'this is __doc__:文档字符串'
>>> fuc()
doc
>>> 

 PyDoc:help函数

通过调用help函数,可以取得相关函数、类、模块等参数的一些辅助信息

>>> class help_():
        pass
>>> help(help_)
Help on class help_ in module __main__:

class help_(builtins.object)
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)

 

posted on 2013-11-07 00:28  kolaman  阅读(177)  评论(0)    收藏  举报