侧边栏壁纸
博主头像
cn2linux博主等级

行动起来,活在当下

  • 累计撰写 128 篇文章
  • 累计创建 1 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

草稿:Python 多行字符串

方法一

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

0

评论区