首页 > 其他 > 详细

读写文件

时间:2018-06-27 23:24:42      阅读:191      评论:0      收藏:0      [点我收藏+]
import re

def readfile(path):
f=open(path)
lines=f.readlines()
f.close()

return lines

def writefile(path,lines):
f=open(path,‘w‘)
f.writelines(lines)
f.close()

def processContents(lines):
for i in range(len(lines)):
if(lines[i]):
lines[i] = re.sub(‘http:‘,‘https:‘,lines[i])

return lines

def processFile():

paths=[‘E:\\tt.txt‘]
for path in paths:
lines=readfile(path)
processContents(lines)
writefile(path,lines)

processFile()

读写文件

原文:https://www.cnblogs.com/xiaoxiaocaicai/p/9236469.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!