打印\ n换行作为python pdb中的实际换行符

时间:2015-10-25 17:00:06

标签: python pdb

当我在pdb中并且我有一个大字符串时,有时我想用新行作为实际换行符将其打印出来,而不是在终端中将它们视为\ n。

(Pdb) p large_string
"very large string with newline\nanother line in the large string\n\netc\n"

我宁愿看

(Pdb) printwithnewline large_string
"very large string with newline
another line in the large string

etc
"

任何提示?

3 个答案:

答案 0 :(得分:3)

只需调用普通打印功能:

(Pdb) print(large_string)
very large string with newline
another line in the large string

etc
(Pdb)

答案 1 :(得分:2)

如果使用Python 2.x,则可以导入打印功能:

from __future__ import print_function

(Pdb) print(large_string)
very large string with newline
another line in the large string

答案 2 :(得分:0)

您可以在任何Python命令前加上'!',这样这也适用于Python 2.x:

ids = sock.execute(dbname, uid, pwd, 'product.product', 'search', args, 0, 0, False, context)