这不是来自文件,但这是一个变量的值,如下所示:
fulltext = u'''test1,TEST1
test2,TEST2'''发布于 2012-02-16 16:57:19
lines = fulltext.splitlines()处理\r、\n和它们的组合(也适用于其他操作系统):
>>> 'a\rb\nc\r\nd'.splitlines()
['a', 'b', 'c', 'd']发布于 2012-02-16 16:50:03
for line in fulltext.split('\n'):
# do something with the line发布于 2012-02-16 16:51:29
有点不清楚,但这就是你要找的吗?
string = """line one
line two
line three"""
lines = string.split('\n')https://stackoverflow.com/questions/9308041
复制相似问题