请示例代码用python完成以下需求:while循环运行osstartfilerCUserssDesktopplaylistMP3_DaXueJiangZhimp3 username timesleep230 osstartfilerCUserssDesktopplaylistWAV_TuRanHenXiangNiwav username
import os import time
获取当前用户名
username = os.getlogin()
循环播放音乐
while True: os.startfile(r"C:\Users%s\Desktop\playlist\MP3_DaXueJiangZhi.mp3" % username) time.sleep(230) os.startfile(r"C:\Users%s\Desktop\playlist\WAV_TuRanHenXiangNi.wav" % username) time.sleep(29) os.startfile(r"C:\Users%s\Desktop\playlist\WMA_YiQianGeShangXinDeLiYou.wma" % username) time.sleep(275)
# 判断时间是否超过四个小时
if time.time() - start_time >= 4 * 60 * 60:
# 关闭groove播放器
os.system('taskkill /im groove.exe /f')
brea
原文地址: https://www.cveoy.top/t/topic/f2hc 著作权归作者所有。请勿转载和采集!