python os.system强制用户重新启动计算机输入,延迟时间应为多长
我在代码中指出了我的问题所在,我在问如何获取用户输入,然后将其放入restart命令中 从这些评论中,我可以获得工作时间python os.system强制用户重新启动计算机输入,延迟时间应为多长,python,Python,我在代码中指出了我的问题所在,我在问如何获取用户输入,然后将其放入restart命令中 从这些评论中,我可以获得工作时间restart=“shutdown-r-t%d”您试过了吗 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 he
restart=“shutdown-r-t%d”
您试过了吗
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)
?
此外,原始输入通常比输入更可取——它更安全。input()将计算用户键入的任何内容。您尝试过吗
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)
?
此外,原始输入通常比输入更可取——它更安全。input()将计算用户键入的任何内容。您只是问如何格式化字符串吗?请解释您的问题是什么您只是问如何格式化字符串吗?请解释您的问题是什么我尝试了重新启动='shutdown-r-t%ds'%time,但不起作用,%d但是,我尝试了重新启动='shutdown-r-t%ds'%time,但不起作用,但%d没有。