How to make a Windows 10 computer go to sleep with a python script?
问题 How can I make a computer sleep with a python script? It has to be sleep , not hibernate or anything else. I have tried to use cmd but there is no command to sleep or I didn't find one. 回答1: You can use import os os.system("rundll32.exe powrprof.dll,SetSuspendState 0,1,0") If this command doesn't work for you (it actually puts your comp. in hibernation mode) you will need to turn hibernation off: Powercfg -H OFF To turn hibernation mode back on: Powercfg -H ON Alternatively, you can also use: