本文实例为大家分享了python定时关机的具体代码,供大家参考,具体内容如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# coding: utf-8
import sys
import os
import time
reload (sys)
sys.setdefaultencoding( "GBK" )
# shutdown computer after time_diff seconds
def shutdown(seconds):
print str (seconds) + u ' 秒后将会关机...'
time.sleep(seconds)
print u '关机啦。。。'
os.system( 'shutdown -s -f -t 1' )
def main():
hour = input (u '延迟关机小时数:' )
print hour
shutdown(hour * 3600 )
if __name__ = = '__main__' :
main()
|
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/asmcvc/article/details/50857861