import os
time = int(input("How many seconds do you want to delay restart?"))
chkdsk = "chkdsk /f C:"
restart = "shutdown -r -t ????" ####My problem is right here, how do i get
#the time input into that command
canrestart = "shutdown -a"
os.system(chkdsk)
os.system(restart)
print("Press enter key to cancel restart")
input()
os.system(canrestart)
我在#####的代码中放置了我遇到问题的地方我问我如何获取用户输入然后将其放入restart命令。
从评论中我能够restart = "shutdown -r -t %d"% time
开始工作
答案 0 :(得分:1)
你试过吗
restart = 'shutdown -r -t %d' % time
此外,raw_input通常优于输入 - 它更安全。 input()将评估用户输入的任何内容。