python笔记 对txt文件的读写

只是对自己平时用到的东西做个笔记:

python 对txt文件的读写(不考虑安全性)

import os
fValfile = open('C:/Users/Zhang.Xu/Desktop/val_test.txt')
valss = open('C:/Users/Zhang.Xu/Desktop/valss.txt','w')
for each_line in fValfile:
    temp = each_line.replace("/mnt/datashare/MIP/Gastric32/","I:/F/胃镜图像库/裁剪后resize32/")
    valss.write(temp)
valss.close()
fValfile.close()

功能就是将一个文件中众多图片的路径修改为其他的路径

猜你喜欢

转载自blog.csdn.net/chengzhongxuyou/article/details/59482979