import os

username = os.getlogin() path = 'C:\Users{}\Documents\PassMark\BurnInTest'.format(username)

fail_found = False for file in os.listdir(path): if 'BIT_log' in file and file.endswith('.log'): with open(os.path.join(path, file), 'r') as f: if 'fail' in f.read(): fail_found = True break

if fail_found: with open(os.path.join(path, 'fail.txt'), 'w') as f: f.write('Fail found in BurnInTest logs') else: with open(os.path.join(path, 'ok.bat'), 'w') as f: f.write('echo BurnInTest passed without errors')

Python脚本:检测BurnInTest日志中是否存在失败,并生成相应文件