import os import sys #coding=utf-8 def CountTime(filepath): try: fobj = open(filepath,'rb') total = 0 times = 0 line = fobj.readline() while line: line = line.strip('\r\n') if(line.find('Load Time: ') != -1): endpos = line.find(' ms') total += int(line[11:endpos]) times += 1 line = fobj.readline() except Exception as e2: print(e2) print("open error") fobj.close() print('%s\t avg time:\t %d'%(filepath.split('\\')[-1], total/times)) def ProcessGame(foldpath): for root,dir,filenames in os.walk(foldpath): for filename in filenames: CountTime(os.path.join(root,filename)) if __name__ == "__main__": try: ProcessGame(sys.argv[1]) except Exception as e1: print(e1) print("usage:1.py d:\\test")