Python: put each line of words in a list
This question already has an answer here:
Im not sure why you used the split function. Instead i think the following list comprehension will help you.
f = open('animal.txt','r')
myList = [line.strip() for line in f]
f.close()
Hope it helps.
链接地址: http://www.djcxy.com/p/42352.html下一篇: Python:将每行单词放入列表中