python使用回车符重写多行代码

问题描述 投票:0回答:1

假设我有一个多行字符串列表:

l = [
"""hello
world""",
"""this
is
a
multiline
string""",
"""foo
bar"""
]

for s in l:
    print(s)

hello
world
this
is
a
multiline
string
foo
bar

而不是在每个多行字符串之后打印换行符,我想在列表中打印每个元素,在该列表中,我们将进行的每次迭代都返回到开头,以便多行字符串在最后打印。

如何在python3中实现?

假设我有一个多行字符串的列表:l = [s中的l = [“”“ hello world”“”“,”“这是一个多行字符串”“”“”“” foo bar“”“”] l:打印hello world,这是多行字符串foo bar ...

python-3.x carriage-return
1个回答
0
投票

您也可以使用ANSI序列和colorama模块来使它们也可以在Windows下运行。

© www.soinside.com 2019 - 2024. All rights reserved.