如何使用Python关闭计算机 [英] How to shutdown a computer using Python

查看:98
本文介绍了如何使用Python关闭计算机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个Python脚本,该脚本最终应关闭计算机。

I've written a Python script which should eventually shutdown the computer.

此行是其中的一部分:

os.system("shutdown /p")

它会进行某种形式的关闭,但仍处于打开状态Windows控制面板(用户可以在其中切换计算机用户)。

It makes some sort of a shutdown but remains on the turn-on Windows control pannel (where the user can switch the computer users).

有没有办法完全关闭计算机?

Is there a way to fully shutdown the computer?

我尝试了其他 os.system( shutdown ___)方法都没有成功。

I've tried other os.system("shutdown ___") methods with no success.

还有另一种方法可能会帮助吗?

Is there another method which might help?

推荐答案

import os
os.system('shutdown -s')

此会为您工作。

这篇关于如何使用Python关闭计算机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆