【发布时间】:2023-01-10 15:25:42
【问题描述】:
我的目录中有以下顺序的文件:
COL_1001.png
COL_1002.png
下次我保存文件时,我希望它被保存为
COL_1003.png
我如何使用 python 程序执行此操作,因为我正在使用示例中给出的 shutil
allfiles = os.listdir(src)
c = 1001
for f in allfiles:
if f in files and len(selected_prop)>0:
s = f
s = f.split('.')
s[0] = projCode + '_' + selected_prop[0] + '_COL.' + str(c)
k = '.'.join(s)
shutil.copy( src + '\\' + f, os.path.join(dst,k))
c += 1
谢谢
卡尔蒂基
【问题讨论】:
-
请编辑您的问题并包含所有代码以创建最小的工作示例。例如:
if f in files and len(selected_prop)>0:什么是files和selected_prop?