import os
import random
rootdir = 'F://F++images//deepfakes_aligned_1'
for root,dirs,files in os.walk(rootdir):
for dir in dirs:
print(os.path.join(root,dir))
num = 0;
for file in files:
feed = random.randint(0, 10)
if feed <= 5:
os.remove(os.path.join(root,file))
print(feed)
print(os.path.join(root,file), file)
num = num + 1
print(num)
将文件夹中的子文件夹中的图片随机删除一半
最新推荐文章于 2023-03-26 22:00:38 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)