zoukankan      html  css  js  c++  java
  • 文件拷贝

    #coding=utf-8
    import os 
    import os.path 
    import shutil 
    import time,  datetime
    
    def copyFiles(sourceDir,  targetDir): 
        for file in os.listdir(sourceDir): 
            sourceFile = os.path.join(sourceDir,  file) 
            targetFile = os.path.join(targetDir,  file) 
            if os.path.isfile(sourceFile): 
                if not os.path.exists(targetDir):  
                    os.makedirs(targetDir)  
                if not os.path.exists(targetFile) or (os.path.exists(targetFile) and (os.path.getsize(targetFile) != os.path.getsize(sourceFile))):  
                    open(targetFile, "wb").write(open(sourceFile, "rb").read()) 
            if os.path.isdir(sourceFile): 
                First_Directory = False 
                copyFiles(sourceFile, targetFile)
    print copyFiles("/home/user/Application/tomcat/apache-tomcat-8.0.30/wtpwebapps/CLZ/static/upload/", "./")

     服务器文件备份

  • 相关阅读:
    Android开发环境
    安卓学习
    Shuffle'm Up POJ
    Duizi and Shunzi HDU
    Find a path HDU
    Cyclic Nacklace HDU
    Keywords Search HDU
    HDU 1495 非常可乐
    J
    Fire Game FZU
  • 原文地址:https://www.cnblogs.com/guoke-jsp/p/7503485.html
Copyright © 2011-2022 走看看