Paging output from print statement

后端 未结 3 1995
隐瞒了意图╮
隐瞒了意图╮ 2021-01-04 02:52

I\'m essentially trying to achieve this:

>>>print \"SOME_VERY_LONG_TEXT\" | more

Of course, it doesn\'t work in Python 2.7(IDLE).

3条回答
  •  情书的邮戳
    2021-01-04 03:08

    You could call it as an external process. (You have to be careful with shell=True, though.)

    import subprocess
    longStr = 'lots of text here'
    subprocess.call(['echo "'+longStr+'" | more'], shell=True)
    

提交回复
热议问题