将多行字符串拆分为行列表

5年以前  |  阅读数:440 次  |  编程语言:Python 

以下函数可用于将多行字符串拆分为行列表。

def split_lines(s):
    return s.split('\n')
split_lines('50\n python\n snippets') # ['50', ' python', ' snippets']

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8