shutting down computer (linux) using python
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to write a script that will shut down the computer if a few requirements are filled with the command os.system("poweroff") also tried os.system("shutdown now -h") and a few others. but nothing happens when I run it, the computer goes through the code without crashing or producing any error messages and terminates the script normally, without shutting down the computer. How does one shutdown the computer in python? edit: Seems that the commands I have tried requires root access. Is there any way to shut down the machine from the