f=open('ceshi.txt','a',encoding='utf-8')r=open('ceshi.txt','r',encoding='utf-8')上面的2种写法可以用with来写:with open('ceshi.txt','a',encoding='utf-8') as f:或with open('ceshi.txt','r',encoding='utf-8') as r:这两个写法不需要用f.close()和r.close() #ceshi.txt里面已经分行展示了first
转载请标明出处: :http://blog.csdn.net/huaiyiheyuan/article/details/52473984 android SD卡主要有两种存储方式 Internal . External Storage Internal 特点 It's always available. Files saved here are accessible by only your app. When the user uninstalls your app, the system r
读文件: 读取文件 f = open('\info.txt') fil = f.read() f.close() 按行读文件: f = open("info.txt") while 1: line = f.readline() line=line.strip('\n') # 去掉换行符 if not line: break print line f.close()