shutil.move删除了我所有的照片 [英] shutil.move deleted all my photos

查看:229
本文介绍了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删除了我所有的照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆