[英]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"""
The python parser takes any end-of-line \
in the code followed by no characters as a line break for the parser : python 解析器将代码中的任何行尾
\
后跟任何字符作为解析器的换行符:
x = """\
some
indented
stuff"""
str = """ some indented stuff""" def formatter(my_str): return '\n'.join([elem.strip() for elem in my_str.split('\n')[1:]]) print(formatter(str))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.