2004年08月25日 星期三 09:03
内置函数help(object)可以打印帮助。我想在程序中象处理字符串一样处理这个帮助,但下面的例子不成:
>>> doc = help('os')
>>> print doc
因为help的返回值是None,所以doc也是None。
请教如何把帮助传给doc这个变量?谢谢。
2004年08月25日 星期三 09:21
Hollo tocer:
咦咦咦??
help('os')
不能加 ''的!
help 实际是进行打印模块的说明字串
class os:
"""说明文本
"""
所以是需要确定的对象!而不是字串哪!
直接 os.__doc__
也可以的!
/******** [2004-08-25]09:20:21 ; tocer wrote:
tocer> 内置函数help(object)可以打印帮助。我想在程序中象处理字符串一样处理这个帮助,但下面的例子不成:
>>>> doc = help('os')
>>>> print doc
tocer> 因为help的返回值是None,所以doc也是None。
tocer> 请教如何把帮助传给doc这个变量?谢谢。
********************************************/
--
Free as in Freedom
Zoom.Quiet
#=========================================#
]Time is unimportant, only life important![
#=========================================#
sender is the Bat!2.12.00
2004年08月25日 星期三 10:04
> 咦咦咦??
> help('os')
> 不能加 ''的!
可以的,不信你在idle里去试试:)
2004年08月25日 星期三 10:07
os.__doc__的信息量有点少,我想要更多的:) ----- Original Message ----- From: "Zoom.Quiet" <zoomq at infopro.cn> To: "tocer" <python-chinese at lists.python.cn> Sent: Wednesday, August 25, 2004 9:21 AM Subject: Re: [python-chinese] 怎样把help(object)的结果传给一个变量 > Hollo tocer: > > 咦咦咦?? > help('os') > 不能加 ''的! > help 实际是进行打印模块的说明字串 > class os: > """说明文本 > """ > 所以是需要确定的对象!而不是字串哪! > > 直接 os.__doc__ > 也可以的! > > > > /******** [2004-08-25]09:20:21 ; tocer wrote: > > tocer> 内置函数help(object)可以打印帮助。我想在程序中象处理字符串一样处理这个帮助,但下面的例子不成: > >>>> doc = help('os') > >>>> print doc > tocer> 因为help的返回值是None,所以doc也是None。 > > tocer> 请教如何把帮助传给doc这个变量?谢谢。 > > > ********************************************/ > > -- > Free as in Freedom > > Zoom.Quiet > > #=========================================# > ]Time is unimportant, only life important![ > #=========================================# > > sender is the Bat!2.12.00 > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese >
2004年08月25日 星期三 10:31
On 2004-08-25 10:04:1093399485 +0800, tocer wrote:
> > 咦咦咦??
> > help('os')
> > 不能加 ''的!
>
> 可以的,不信你在idle里去试试:)
help 是一个交互用的函数,它只会把文档信息*打印*出来,不会
放到返回值里的。自己去找或者编写更复杂的取对象信息的方法。
Zeuux © 2025
京ICP备05028076号