如何使用 Python 在文本模式下创建可滚动屏幕 [英] How to create a scrollable screen in text mode with Python

查看:31
本文介绍了如何使用 Python 在文本模式下创建可滚动屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在文本模式下创建一个可滚动屏幕,就像在解释器中键入 help(object) 时获得的屏幕一样.是否有我可以使用的跨平台模块来轻松实现这一点?

例如:

<预><代码>>>>def jhelp(对象):>>>text = # 获取对象的文本>>>display_text(text) # 显示一个可滚动的屏幕.我该怎么做呢?>>>>>>l = [1,2,3]>>>jhelp(l)

解决方案

from pydoc import ttypagerdef jhelp(对象):text = # 获取对象的文本ttypager(text) # 显示一个可滚动的屏幕.

I would like to create a scrollable screen in text mode, like the one obtained when typing help(object) in the interpreter. Is there a cross-platform module I can use to easily implement this?

For example:

>>> def jhelp(object):
>>>     text = # get text for object
>>>     display_text(text) # display a scrollable screen. How do I do this?
>>>
>>> l = [1,2,3]
>>> jhelp(l)

解决方案

from pydoc import ttypager

def jhelp(object):
     text = # get text for object
     ttypager(text) # display a scrollable screen.

这篇关于如何使用 Python 在文本模式下创建可滚动屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆