python特别注释_写好python的注释文档很容易

下面是一段非常简单的foo.py

#!usr/bin/env python

"""foo.py -- this is a demo"""

classFoo(object):"""Foo - this is a empty class,to be developed"""

defprintdoc(x):"""bar(x) - to print the parameters 'x'"""

print x

在python中执行如下过程:

>>> import foo

通过__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'"

也可以通过内置函数help

>>> help(foo)

Help on module foo:

NAME

foo - foo.py -- this is my first damo

FILE

/django/foo.py

CLASSES

__builtin__.object

Foo

class Foo(__builtin__.object)

| Foo -- this is empty class,to be devloped

|

| Data and other attributes defined here:

|

| __dict__ =

| dictionary for instance variables (if defined)

|

| __weakref__ =

| list of weak references to the object (if defined)

FUNCTIONS

bar(x)

bar(x)- to print the para 'x'

同样help也可用于查询很多你想要的东西

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值