#coding:utf-8 import sys reload(sys) sys.setdefaultencoding('utf-8') import time def logs(method): def wrapper(*args, **kwargs): print u'方法[{0}],開始執行'.format(method.func_name) start = time.time() ret = method(*args, **kwargs) print u'方法[{0}],執行完成,用時{1}s'.format(method.func_name, time.time() - start) return ret return wrapper @logs def parse(strx): infoList = strx.split('\n') for info in infoList: if len(info.split(',', 1)) == 1: continue email, errMsg = info.split(',', 1) print email, errMsg if __name__ == '__main__': with open('base.txt', 'r') as f: strx = f.read() parse(strx)