有没有一种方法可以防止Windows 10计算机在Python中进入睡眠状态?
与此处发布的问题基本相同,但对于Windows 10:Prevent OS X from going to sleep with Python?
是否可以从Python调用Windows命令?
我正在使用Python 3.6,如果有什么区别。
这可能不是直接的答案,但是会起作用。您可以使用PyAutoGUI以特定的间隔单击特定的屏幕位置。这将迫使您的计算机无法进入睡眠状态
import time
import pyautogui
# press ctrl+c to get out of the loop
while(True):
pyautogui.click(x=100, y=200) # make sure noothing is there in the clicked location
time.sleep(10)