再总计下python-logging模块
#-*-coding:utf-8-*-
import logging
import logging.handlers
import time
try:
logger1 = logging.getLogger()#实例
logger2 = logging.getLogger()
logger1.setLevel(logging.DEBUG)#定义BUG级别
format = logging.Formatter('%(asctime)s-%(name)s-%(message)s',datefmt=time.strftime('%Y%m%d'))#格式
fh=logging.FileHandler('D:\\doc\\hello.log')#文件句柄
fh.setLevel(logging.DEBUG)
fh.setFormatter(format)
logger1.addHandler(fh)#添加文件句柄
logger1.debug('hello')
ch=logging.FileHandler('D:\\doc\\he.log')
ch.setLevel(logging.INFO)
ch.setFormatter(format)
logger2.addHandler(ch)
logger2.info('hello11')
except Exception ,e:
print e
另外一个python操作excel:
简单的说,就是
读取一张表格->读取具体的一张表单->读取行列数据
#-*-coding:UTF-8-*-
import xlrd
from urllib2 import urlopen
excel=xlrd.open_workbook('d:\\doc\\quanshang.xls')//读取一个excel
sheet=excel.sheet_by_index(0)//读取某一张表单
url_columu=sheet.col_values(3)//读取某一列,返回一个list
md5_columu=sheet.col_values(4)
i=j=0
for num in range(1,len(url_columu)):
text=urlopen(url_columu[num].encode("utf-8")).read()
if text.find(md5_columu[num].encode("utf-8"))!= -1:
print 'find'
i=i+1
else:
print 'sorry',num+1
j=j+1
print i
获取每一行的信息
#打印每行的信息
for rownum in range(sheet.nrows):
#每一行的信息
print sheet.row_values(rownum) #列表
最后根据索引来确定:
cell_A1 = sheet.cell(0,0).value
X是row,Y是col