Paging output from python

后端 未结 5 1479
心在旅途
心在旅途 2020-12-09 02:16

I\'m trying to implement something similar to git log, which will only page the output if the log is of a certain length. If you\'re not familiar with git, I\'

5条回答
  •  天涯浪人
    2020-12-09 03:11

    How about this:

    import pydoc
    text = '... some text ... '
    pydoc.pager(text)
    

    This (on my opensuse linux box) sends the text to a pager ('less' in my case), and works the same as calling "help(... python command...)" within the Python interpreter.

提交回复
热议问题