方法一:
with open('filename','r') as f: #读入文件
L = [i.strip().split() for i in f] #strip()函数,默认删除字符串头和尾的空白字符
print(L)
也可以这样读入文件:
f= open(r'filename','r') #读入文件
L = [i.strip().split() for i in f]
print(L)
f.close()