convert file data to list
プログラムソース
def readFile(fileName):
#opens the file in read mode.
fileObj = open(fileName, "r")
#puts the file into an array.
words = fileObj. read(). splitlines()
fileObj. close()
return words
a1=readFile("test.txt")
print(a1)
結果
===== RESTART: C:/python/convertFileToList.py ==========
['112222', 'aaaaa', 'mmmmm', 'aaaaaaa']
>>>
コメント
コメントを投稿