Python文件IO 有如下文本内容,文件路径为D:\temp,文件名称为lyric.txt, line1 Look ! line2 If U had one shot line3 One opportunity line4 To seize everything U ever wanted line5 One moment line6 Would U capture it ? line7 Or just let it slip 逐行读取,并输出 #coding=utf-8 import os…
第一天 文件IO处理 1.读文件实例 file_split.python f = file('myFile.txt', 'r') for line in f.readlines(): line = line.strip('\n').split(':') print line myFile.txt ## # User Database # # Note that this file is consulted directly only when the system is running #…