下面是一段很是簡單的foo.pypython
#!usr/bin/env python """foo.py -- this is a demo""" class Foo(object): """Foo - this is a empty class,to be developed""" def printdoc(x): """bar(x) - to print the parameters 'x' """ print x
在python中執行以下過程:
>>> import foodjango
經過__doc__屬性訪問模塊、函數、類的文檔
>>> foo.__doc__
'foo.py -- this is my first damo'
AttributeError: type object 'Foo' has no attribute '__doc'
>>> foo.Foo.__doc__
'Foo -- this is empty class,to be devloped'
>>> foo.bar.__doc__
"bar(x)- to print the para 'x'"函數
也能夠經過內置函數helpui
>>> help(foo)
Help on module foo:this
NAME
foo - foo.py -- this is my first damospa
FILE
/django/foo.pycode
CLASSES
__builtin__.object
Fooblog
class Foo(__builtin__.object)
| Foo -- this is empty class,to be devloped
|
| Data and other attributes defined here:
|
| __dict__ = <dictproxy object>
| dictionary for instance variables (if defined)
|
| __weakref__ = <attribute '__weakref__' of 'Foo' objects>
| list of weak references to the object (if defined)文檔
FUNCTIONS
bar(x)
bar(x)- to print the para 'x'io
一樣help也可用於查詢不少你想要的東西