您的位置:首页 > 编程语言 > Python开发

python定时关机小脚本

2018-06-20 09:57 567 查看

本文实例为大家分享了python定时关机的具体代码,供大家参考,具体内容如下

# 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()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python 关机