Search code examples
pythonpython-3.xstringmultiline

Python skip first line of multiline string


Is there a way to skip the first line of a multiline string? So that I can do this:

str = """
  some
  indented
  stuff"""

instead of

str = """  some
  indented
  stuff"""

Solution

  • The python parser takes any end-of-line \ in the code followed by no characters as a line break for the parser:

    x = """\
      some
      indented
      stuff"""