【发布时间】:2019-05-30 02:10:01
【问题描述】:
我有大约 10 分钟的视频,只是提取到每一帧中,所以我的文件夹中有超过 100,000 张图像,并将它们从 1 重命名为 100,000。现在我想从 1 到 100,000 张图像中选择每 30 张中的 1 张并将它们移动到另一个文件夹。例如:1、31、61、91、121、151、181等。
这是我目前的代码:
import os
import shutil
PATH = './Folder1/'
DEST = './Folder2/'
file = 1
for file in os.listdir(PATH):
file = file + 30
shutil.copyfile(PATH, DEST)
但它给了我以下错误:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-b08091703697> in <module>
9 # Get a list of files in the current working directory
10 for file in os.listdir(PATH):
---> 11 file = file + 30
12 shutil.copyfile(PATH, DEST)
TypeError: can only concatenate str (not "int") to str
提前感谢您的帮助!
【问题讨论】:
标签: python python-3.x file file-io shutil