#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
#from os import system
import os
runing = True
while runing:
inputs =input("关机(s)OR重启(r)?(q退出)")
# inputs = input.lower()
if inputs == 'q' or inputs == 'quit':
runing = False
print ("程序退出")
break
seconds = int(input("请输入暂停时间(单位:秒):"))
# a =input("sleep time:")
time.sleep(seconds)
print("暂停时间:", seconds)
runing = False
if inputs == 's':
print("关机ing")
os.system("shutdown -s -t 60 ")
elif inputs == 'r':
print("重启ing")
# system('reboot')
else:
print("程序错误重新输入")
runing = True
print("程序结束~~~!")python实现自动关机
最新推荐文章于 2025-09-14 22:05:26 发布
本文介绍了一个使用Python编写的简单脚本,该脚本允许用户选择进行系统关机或重启操作,并包含暂停功能。通过命令行交互,用户可以输入指令来决定执行的操作并设置暂停时间。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Python3.11
Conda
Python
Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本
1201





