How does Python's triple-quote string work?

后端 未结 9 1071
野性不改
野性不改 2020-12-09 08:09

How should this function be changed to return \"123456\"?

def f():
    s = \"\"\"123
    456\"\"\"
    return s

UPDATE: Everyo

9条回答
  •  囚心锁ツ
    2020-12-09 08:27

    def f():
      s = """123\
    456"""
      return s
    

    Don't indent any of the blockquote lines after the first line; end every line except the last with a backslash.

提交回复
热议问题