zoukankan      html  css  js  c++  java
  • 定时处理

    #清理文件夹
    def clear_file(path_data):
        try:
            for i in os.listdir(path_data) :
                # os.listdir(path_data)#返回一个列表,里面是当前目录下面的所有东西的相对路径
                file_data = path_data + "\" + i
                print("清理文件夹中......")
                #当前文件夹的下面的所有东西的绝对路径
                if os.path.isfile(file_data) == True:
                    #os.path.isfile判断是否为文件,如果是文件,就删除.如果是文件夹.递归给del_file.
                    os.remove(file_data)
                else:
                    clear_file(file_data)
                    print("清理文件夹成功")
        except Exception as e:
            print(e)
    
    #函数定义休眠时间
    def sleeptime(hour, min, sec):
        try:
            return hour * 3600 + min * 60 + sec
        except Exception as e:
            print(e)
    
    #定时循环执行清理log/picture
    def circulation(hour,min,sec):
        try:
            hour1 = hour
            min1  = min
            sec1  = sec
            second = sleeptime(hour1,min1,sec1)
            while 1 == 1:
                # 延时
                time.sleep(second)
                # 执行
                print("定时清理log/picture........")
                #清理Llog
                clear_file(logspath)
                #清理picture
                clear_file(picturepath)
        except Exception as e:
            print(e)
  • 相关阅读:
    CodeForces
    CodeForces
    FZU
    FZU
    UESTC
    测试用例概述
    软件测试流程
    软件测试(二)软件测试过程
    软件测试(一)软件的生命周期(SDLC,Systems Development Life Cycle,SDLC)
    系统测试的策略
  • 原文地址:https://www.cnblogs.com/xiaochuichui/p/13280922.html
Copyright © 2011-2022 走看看