Python3 读取字符串的第一行


In [1]: my_string = """This is my first line,
   ...: this is my second line, and...
   ...:
   ...: ...this is my fourth line!"""

In [2]: my_string.splitlines()[0]
Out[2]: 'This is my first line,'

In [3]: my_string.split('\n', 1)[0]
Out[3]: 'This is my first line,'