from ctypes import * user32 = windll.LoadLibrary('user32.dll') user32.LockWorkStation()上述代码同win+L 锁屏功能相同