zoukankan      html  css  js  c++  java
  • python3 移动文件

    code1

    import os
    import shutil
     
    pwd=os.getcwd()
    fpath
    =os.path.join(pwd,"dian") target=os.path.join(pwd,"电子书") c=0 for i in os.listdir(fpath): d=os.path.join(fpath,i) if(os.path.isdir(d)): for j in os.listdir(d): f=os.path.join(d,j) trail=j.split(".")[-1] if(trail=="pdf"): shutil.move(f,target) c+=1 print("移动{}次".format(c))

     code2

    import os
    import shutil
     
    
    pwd=os.getcwd()
    fpath=os.path.join(pwd,"pic")
    target=os.path.join(pwd,"tmp")
    
    c=0
    
    for i in os.listdir(fpath):
        
        d=os.path.join(fpath,i)
        if(i.startswith(".")):
            continue
        c+=1
        if(os.path.isdir(d)):
            yulan=os.path.join(d,"yulan")
            for j in os.listdir(yulan):
                f=os.path.join(yulan,j)
                if("mini" in j):
                    shutil.move(d,target)
                    break
                    
                
    print("移动{}次".format(c))

  • 相关阅读:
    Docker容器查看ip地址
    抽象工厂模式
    idea插件
    作业统计
    tarjan强连通图分量
    Android动画浅析
    位运算
    mongodb笔记
    依赖倒置原则
    单一职责原则
  • 原文地址:https://www.cnblogs.com/sea-stream/p/13960697.html
Copyright © 2011-2022 走看看