有没有一种简单的方法来打印一个包含换行符
基本上,我有类似下面的东西:
问题在于新行的下一行不会从第十列开始:
\n
的字符串,并在一定数量的字符后左对齐?基本上,我有类似下面的东西:
A = '[A]: '
B = 'this is\na string\nwith a new line'
print('{:<10} {}'format(A, B))
问题在于新行的下一行不会从第十列开始:
[A]: this is
a string
with a new line
我希望你能为我提供一些类似的内容
[A]: this is
a string
with a new line
我可以把B
分开,但我想知道是否有更好的方法。
'\n'
替换为'\n '
怎么样?(包括10个空格) - Willem Van Onsem