python定时关机工具

    简单的python代码,使用tkinter库实现交互,定时关机,适用于windows系统。

import os
import sys
import time
import tkinter as tk
from threading import Thread
from tkinter import ttk

def get_time():#获取当前的时间
    h=time.strftime("%H", time.localtime())
    m=time.strftime("%M", time.localtime())
    if len(h)==1:
        h="0"+h
    if len(m)==1:
        h="0"+h
    return (h,m)
def close_threading(hour,min):#监测时间并且关机电脑的子线程
    global thread_running
    bool=True
    while bool and thread_running:
        time=get_time()
        if (time[0]==hour and time[1]==min):
            bool=False
    if not(bool):
        os.system("shutdown -s -t 0")#cmd关机命令
threading=True#控制时间检测线程
def window2(hour,min,root=False):
    def open_window1(root):
        global thread_running
        thread_running=False
        window1(root)
    if root!=False:
        for i in root.winfo_children():
            i.destroy()
    else:
        root = tk.Tk()
    global thread_running
    t
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值