txt文档里有文件路径,将此路径下的文件复制到另一个新路径python

txt内容如下,存放的为文件路径:
在这里插入图片描述

#txt文档里有图片路径,将此路径下的图片复制到另一个新路径
import shutil
newpath=r'C:\Users\Desktop\test'
path = []
with open(r'C:\Users\Desktop\test.txt' ,'r') as f:
    for line in f:
        print(line)
        shutil.copy(line.strip(), newpath) #strip()用于移除字符串头尾指定的字符(默认为空格或者换行符)或字符序列

猜你喜欢

转载自blog.csdn.net/weixin_44769034/article/details/124697279