Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用ipdb调试 python 脚本。
ipdb
我想打印一个很长的变量。是否有任何类似more或less用于 shell 的 ipdb 寻呼机?
more
less
谢谢
您可能想要创建一个函数来接受文本,将此文本放入临时文件,然后调用os.system('less %s' % temporary_file_name).
os.system('less %s' % temporary_file_name)
为了使其更易于日常使用:将函数放入文件(例如~/.pythonrc:)并在PYTHONSTARTUP.
~/.pythonrc
PYTHONSTARTUP
或者,您可以只安装bpython( pip install bpython),然后使用bpython. 这个 shell 有一个“寻呼机”功能,它less与您的最后一个输出一起执行。
bpython
pip install bpython