from pygments.lexers import RstLexer
from pygments.formatters import TerminalFormatter
from pygments import highlight
output = highlight(source, RstLexer(), TerminalFormatter())
p = subprocess.Popen('less', stdin=subprocess.PIPE)
p.stdin.write(output)
p.stdin.close()
p.wait()
当我只是print output
- 一切都很好,但管道断裂突出显示......有什么想法吗?
例子: