📅  最后修改于: 2022-03-11 14:45:32.770000             🧑  作者: Mango
import ctypes
import sys
def admin():
try: return ctypes.windll.shell32.IsUserAnAdmin()
except Exception: return False
if not admin(): # If not ran as administrator, re-run it as administrator!
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
sys.exit()