def rename_img(path)
    start = time.clock()#计算程序开始执行
    count=0
    for root,dirs,files in os.walk(path):    #遍历统计
        for each in files:  
            url=path+"\\"+each; #原文件的路径+文件名(绝对路径)
            count=count+1;
            os.rename(url,path+"//N"+str(count)+".jpg")
    elapsed = (time.clock() - start) #计算程序结束
    print("running time:"+str(elapsed)+"s") #显示程序的执行时间

这里将所有的文件命名为:

python 重命名文件

重命名函数:os.rename(原来绝对路径,现在绝对路径)

相关文章:

  • 2021-10-16
  • 2021-06-18
  • 2021-12-10
  • 2021-10-09
  • 2022-02-21
  • 2021-04-17
  • 2022-01-27
  • 2021-11-18
猜你喜欢
  • 2021-06-18
  • 2022-02-13
  • 2021-11-27
  • 2021-11-29
  • 2021-09-24
  • 2021-11-18
  • 2021-11-18
相关资源
相似解决方案