把目录 E:\ 下面所有 后缀名为 .py 的 文件复制到 E:\PyLearn

#coding:utf-8

import os
import shutil

def getfile(srcDir,dstDir,extName):
    filelist = os.listdir(srcDir)
    for tgFile in filelist:
        tgFilePath = os.path.join(srcDir,tgFile)
        if os.path.isfile(tgFilePath) == True:
            tgFile_tuple = os.path.splitext(tgFilePath)
            if tgFile_tuple[1] == extName:
                shutil.copy(tgFilePath,dstDir)

srcDir = 'e:' + os.sep
dstDir = 'e:' + os.sep + 'LearnPy'
extName = '.py'
getfile(srcDir,dstDir,extName)

 

相关文章:

  • 2022-12-23
  • 2021-09-10
  • 2022-01-11
  • 2022-12-23
  • 2021-09-17
  • 2021-12-03
  • 2021-10-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
  • 2021-08-26
  • 2022-12-23
相关资源
相似解决方案