使用输入函数指定关机时间

2024-05-15 16:24:25 发布

您现在位置:Python中文网/ 问答频道 /正文

编辑脚本以使用input()函数查询用户的关机超时时间。编辑脚本以使用另一个input()函数查询用户,以获取在机器执行关机时显示的消息。我有问题使用输入功能,要求用户关闭电脑一段时间,也要求他们显示一条消息。在

import os

#chkdsk = "chkdsk C:"
#os.system(chkdsk)

print("How much time till shutdown?")
time = input() 
print (time)

shutdown = 'shutdown", "-f", "-r", "-t", "-c", MESSAGE HERE'
os.system(shutdown)

Tags: 函数用户脚本机器消息编辑inputtime
2条回答

你只要用那句话:

x = int(input("How much time till shutdown?"))

我没听错吧:你想把时间放在绳子里吗?在

shutdown = 'shutdown -f -r -t {time} -c MESSAGE HERE'
os.system(shutdown.format(time=time))

相关问题 更多 >