这是我以前写的定时关机小程序,主要就是通过time.strftime来获取时间的
python 有一个Timer模块,可以实现定时器功能,你可以参考一下https://blog.csdn.net/saltriver/article/details/52194915
楼上的方法不能说不可用,但效率有问题,最好用Timer模块。