python 对txt中每行内容进行批量替换
来源:互联网 发布:相片合成软件 编辑:程序博客网 时间:2024/04/29 02:57
f = open('./val.txt')
lines = f.readlines() #整行读取
f.close()
for line in lines:
rs = line.rstrip('\n') #去除原来每行后面的换行符,但有可能是\r或\r\n
newname=rs.replace(rs,'/JPEGImages/'+rs+'.jpg'+' '+'/SegmentationClassAug/'+rs+'.png')
newfile=open('.val1.txt','a')
newfile.write(newname+'\n')
newfile.close()
lines = f.readlines() #整行读取
f.close()
for line in lines:
rs = line.rstrip('\n') #去除原来每行后面的换行符,但有可能是\r或\r\n
newname=rs.replace(rs,'/JPEGImages/'+rs+'.jpg'+' '+'/SegmentationClassAug/'+rs+'.png')
newfile=open('.val1.txt','a')
newfile.write(newname+'\n')
newfile.close()
原文件 改后
阅读全文
0 0
- python 对txt中每行内容进行批量替换
- python批量替换Excel中内容
- Python批量替换文本内容
- sql中对text字段里面的内容进行替换
- 使用python对txt,excel批量操作
- python中怎么对文件中的单词进行替换
- Sql批量替换所有表中内容
- Sql批量替换所有表中内容
- linux批量替换文本中内容
- Access中批量替换数据库内容
- Python 替换文件中内容
- java中,对文件进行追加内容到txt的三种方法
- android 读取txt文件获取每行内容
- mysql 批量替换 内容
- Eclipse 内容批量替换
- 文件内容批量替换
- Python对文件进行批量随机重命名
- Python对文件进行批量随机重命名
- 虚幻4崩溃问题解决方案
- nginx安装不能下载pcre yum更新问题resolve host 'mirrors.vonline.vn'"
- 注意事项!机械行业ERP系统如何选型
- jQuery报错:Uncaught ReferenceError: $ is not defined
- 运行jar包出现问题:java.lang.SecurityException: JCE cannot authenticate the provider BC
- python 对txt中每行内容进行批量替换
- mmc命令
- windows 2012 R2 及 centos 7.X 禁用不必要服务
- Android 关于volley的一些源码和扩展 (一)
- 哪款扫地机器人好用,科沃斯DD35
- SAP-MM自动记账解析之基本概念
- volatile关键字解析
- Hello CSDN
- PAT甲级1132 Cut Integer (20)