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

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

问题描述

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

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

这一行是其中的一部分:

This line is a part of it :

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天全站免登陆