码迷,mamicode.com
首页 > 其他好文 > 详细

Game

时间:2014-09-02 19:42:55      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:blog   os   io   ar   for   div   sp   log   on   

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")

  

Game

标签:blog   os   io   ar   for   div   sp   log   on   

原文地址:http://www.cnblogs.com/xiaobaichuangtianxia/p/3951881.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!