If you want to shutdown your Windows PC from your Python code, just use this code snippet.

import os
os.system("shutdown /s /t 1")

That’s it. I hope this helps. Do you recommend reading this blog post? share it!