帮我写个自动开机的代码
这是一个简单的Python代码示例,用于自动开机:
import os
import time
def auto_power_on(hour, minute):
while True:
current_time = time.localtime()
if current_time.tm_hour == hour and current_time.tm_min == minute:
os.system("shutdown -s -t 0")
break
time.sleep(60)
# 设置开机时间为每天的8点30分
auto_power_on(8, 30)
请注意,这个代码示例只适用于Windows操作系统。它使用了os.system()函数来执行命令行指令,具体指令是shutdown -s -t 0,表示立即关机。如果你想要实现其他操作系统或其他开机方式,请提供更多的细节,我将会给予进一步的帮助。
原文地址: https://www.cveoy.top/t/topic/h5Os 著作权归作者所有。请勿转载和采集!