shutil.move删除了我所有的照片

编程入门 行业动态 更新时间:2024-10-17 06:32:52
本文介绍了shutil.move删除了我所有的照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 for i in os.listdir(): if "jpeg" in i or "png" in i: shutil.move(os.path.join(os.getcwd(),i),"my photos")

我想将所有照片移动到一个不存在的名为我的照片"的文件夹中.它创建了一个名为我的照片"的txt文件,但只有300 kb,在我快速查看时,它仅显示我的一张照片.那我该如何找回我的照片呢?他们现在在哪里?

I wanted to move all photos to a folder called "my photos" which is not exist. It created a txt file called "my photos" but it is just 300 kb and when I quickview it it only shows one of my photo. So how can I get my photos back? where are they now?

推荐答案

我相信shutil.move只是拿了每个文件并将我的照片"解释为保存每个文件的名称,而不是将其复制到的目录.对于目录中的每个图像,它都将覆盖它,而我的照片"仅保留最后一个图像的内容.

I believe shutil.move simply took each file and interpreted "my photos" as the name to save each file as rather than a directory to copy it into. For each image in the directory, it would have overwritten it, leaving "my photos" with just the contents of the last image copied.

看看像人们如何使用shutil来移动文件的这样的示例,他们加入了基本目录名称以及形成target参数的文件名.

Looking at examples like this of how people have used shutil for moving files, they join the base directory name and the file name to form the target parameter.

我希望你有备份.

更多推荐

shutil.move删除了我所有的照片

本文发布于:2023-11-01 01:56:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547913.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:我所   照片   shutil   move

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!