Py学习  »  Python

在python中拆分.txt文件中的行

Richard Lewis • 4 年前 • 424 次点击  

我有一个.txt文件:

My
name is
Richard

我想要一些像 ['My', 'name is', 'Richard'] 我试过了

file = open("Text.txt")
strings = file.read()
strings = strings.split()
print(strings)

但它给了我 ['My', 'name', 'is', 'Richard'] 那么我怎样才能一行一行地得到它呢?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/38094
 
424 次点击  
文章 [ 3 ]  |  最新文章 4 年前