递归复制和重命名文件的工作,然后意外停止 上下文代码输出问题

问题描述

上下文

  1. 需要重复复制和重命名图像文件,直到达到特定计数为止。

  2. 重命名部分必须满足某些增加的步骤。

  3. export async function getServerSideProps(context) { const { id } = context.query console.log('getServerSideProps -> context.params',context.params,' context.query',context.query) // const res = await api.get(`/courses/${id}`) // const data = await res.data // console.log('getServerSideProps -> data',data) return { props: { MetaCourse: 'data' } } }

代码

Python 3.7.0

输出

期望图像将具有按顺序编号的名称(即image1.jpg image5.jpg image9.jpg等)

问题

代码工作到image9.jpg,然后在回溯过程中停止,错误为:

import os
import shutil
import glob

fps = 30
timer = 1 #in seconds
count = fps * timer + 1

#input and output file directory
src1 = glob.glob("./src/captured1.jpg")
dest = "./dst/"

#numbering start from 1 with increasing step of 4
for i in range(1,count,4):
    for file_path in src1:
        print(file_path)
        shutil.copy(file_path,dest)
        for filename in os.listdir(dest):
            os.rename(os.path.join(dest,filename),os.path.join(dest,'image'+ str(i) + '.jpg')) 

如何改进代码

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...