# -*- coding: utf-8 -*-

import os

#遍历文件夹删除文件
def traversing_dir(rootDir):
    #遍历根目录
    for root,dirs,files in os.walk(rootDir):
        for file in files:
            #文件后缀名
            extFile=os.path.splitext(file)[1]
            if extFile==".longtian":
                os.remove(os.path.join(root,file))    #删除文件
        for dir in dirs:
            #递归调用自身
            traversing_dir(dir)

if __name__=='__main__':
    path="H:\\"
    traversing_dir(path)

 

相关文章:

  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
猜你喜欢
  • 2022-03-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
相关资源
相似解决方案