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/", "./")

     服务器文件备份

  • 相关阅读:
    Samba
    百度贴吧
    baidu.com关键字查询
    vim 删除每行开头结尾空格
    read line(逐行读取)
    pycharm 激活
    rsync 启动脚本
    收藏
    elk
    sql is null
  • 原文地址:https://www.cnblogs.com/guoke-jsp/p/7503485.html
Copyright © 2011-2022 走看看