【发布时间】:2018-10-05 05:45:02
【问题描述】:
在 Python Idle shell 中,help() 命令的输出不会被分页。有什么方法可以实现吗?
作为一种解决方法,我尝试使用pydoc.pager(),但没有成功。以下在从终端启动的普通 Python shell 中有效,但在 Python Idle shell 中无效。
import pydoc
def ihelp(thing):
'''Render text documentation, given an object or a path to an object, and
sends the resulting text to a pager.'''
pydoc.pager(pydoc.render_doc(thing))
编辑:只是为了避免误解。 ihelp() 函数在终端 Python shell 和 IDLE shell 中获取帮助文本。分页仅在终端 shell 中有效。
【问题讨论】:
标签: python python-idle