方法一
s1 = """Multi line strings can be put
between triple quotes. It's not ideal
when formatting your code though"""
print (s1)
输出:
Multi line strings can be put
between triple quotes. It's not ideal
when formatting your code though
方法二(推荐)
上面示例虽然可以实现字符串换行但是会多出很多空格。
s2 = ("You can also concatenate multiple\n"
"strings this way, but you'll have to\n"
"explicitly put in the newlines")
print(s2)
输出:
You can also concatenate multiple
strings this way, but you'll have to
explicitly put in the newlines
评论区