摘要:
#coding=utf8import cStringIOimport StringIOimport timevalues = []items = ['1,2,31,2,31,2,31,2,3'] * 10000000#print itemsst = float(time.time())for i in items: values.append(i)news = ''.join(values)print len(news)print 'list append cost time:%s'%(float(time.time()) - st)strio 阅读全文
摘要:
#coding=utf8import sys, logginglogging.basicConfig(level=logging.INFO, format='levelname:%(levelname)s filename: %(filename)s ' 'outputNumber: [%(lineno)d] thread: %(threadName)s output msg: %(message)s' ' - %(asctime)s', date... 阅读全文
摘要:
sys.stderr 是用来重定向标准错误信息的,如import sysprint 'this error'sys.stderr.write("this is a error message")在linux 运行时python xx.py 2>/error.log由于命令行的2只有记录错误到文件,所以 error.log就会记录sys.stderr输出的错误信息,而不会记录print 的,当然也能记录到raise文件文件描述符输入文件0输出文件1错误输出文件2如goagent的proxy.py模块对sys.stderr的用法try: import ge 阅读全文