本文实例讲述了Python实现的根据文件名查找数据文件功能。分享给大家供大家参考,具体如下:
#-*- coding: UTF-8 -*-
import os
import shutil
AllFiles=[]
NameFiles=[]
def findFie(filePath):
pathDir = os.listdir(filePath)
for allDir in pathDir:
# print(allDir)
AllFiles.append(allDir)
#pass
#filepath = 'C:\\Users\\IBM_ADMIN\\Desktop\\cognos\\datastage\\71&72\\71\\71sns'
#copyfile = 'C:\\Users\\IBM_ADMIN\\Desktop\\cognos\\datastage\\71&72\\71mtp'
filepath = 'C:\\Users\\IBM_ADMIN\\Desktop\\cognos\\datastage\\71&72\\72\\72sns'
copyfile = 'C:\\Users\\IBM_ADMIN\\Desktop\\cognos\\datastage\\71&72\\72mtp'
shutil.rmtree(copyfile)
os.mkdir(copyfile)
findFie(filepath)
def readFile():
readFile = o