First you have to:
import subprocess
To shutdown your Windows PC:
subprocess.call(["shutdown", "/s"])
To restart your windows PC
subprocess.call(["shutdown", "/r"])
To logout your Windows PC:
subprocess.call(["shutdown", "/l "])
To shutdown your Windows PC after 900s:
subprocess.call(["shutdown", "/s", "/t", "900"])
To abort shutting down because there is no good reason to shutdown your pc with a python script, you were just copy-pasting code from stackoverflow:
subprocess.call(["shutdown", "/a "])
I only tried these function calls in Python 3.5. First of all, I do not think this has changed since python 2.7, and second: it is 2016, so I guess you have made the switch already since asking this question.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…