背景
我目前正在自学python的过程中,我认为有一个"控制中心"是一个非常酷的项目,我可以在其中关闭,重新启动和注销我的计算机.我也想使用子进程模块,因为我听说导入OS模块已经过时了.
现行守则
def shutdown(self):
import subprocess
subprocess.call(["shutdown", "-f", "-s", "-t", "60"])
Run Code Online (Sandbox Code Playgroud)
题
我真正要问的是,有没有办法(使用子进程模块)注销并重启我的计算机?
技术规格
Python 2.7.3
Windows 7,32位