How to shutdown a computer using Python?

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

This coding for shutdown the computer eventually.

After running this code, a message saying “You are about to be signed out in less than a minute”

We can avoid that message – os.system(‘shutdown -s -t 0’) instead of using os.system(‘shutdown -s’) will immediately get shut down.

Leave a Reply