Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
打印\n换行符作为python pdb中的实际换行符_Python_Pdb - Fatal编程技术网

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

打印\n换行符作为python pdb中的实际换行符,python,pdb,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

当我在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
"

有什么提示吗?

只需调用正常的打印功能:

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

etc
(Pdb)
from __future__ import print_function

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

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

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

etc
(Pdb)
from __future__ import print_function

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

您可以在任何Python命令前面加上“!”,因此,这也适用于Python 2.x:

!print large_string

(当你在pdb中打印东西时,你还应该检查
pp
,它的打印效果很好,这对于列表和目录来说非常方便)