标签:编码格式 font lob utf-8 ftime txt time() xls enc
#=======================================================================================20190521以下脚本是通过读取excle路径删除应路进下的日志==============================================================
# -*- coding:utf-8 -*-
# ! /usr/bin/python
# defaultencoding = ‘utf-8‘
#
# import datetime
# import glob
# import time
# import os
# import xlrd
# import xlwt
# from xlutils.copy import copy
#
# time1 = time.strftime(‘%Y%m%d%H%M%S‘, time.localtime(time.time()))
# # today = datetime.date.today()
# # print(today)
# # time3 = datetime.date.today() - datetime.timedelta(days=1)
# # time2 = time3.strftime("%Y%m%d")
# # print( "time2=", time2)
#
#
# def rm_log(path):
# for n in range(1,31):
# time3 = datetime.date.today() - datetime.timedelta(days=n)
# time2 = time3.strftime("%Y%m%d")
# F1 = glob.glob(path + r"\*" + str(time2) + "*")
# F2 = glob.glob(path + r"\*" + ".txt")
# for f1 in F1:
# for f2 in F2:
# if f1 == f2:
# print("f1=", f1)
# if (os.path.exists(f1)):
# print("要删除对应路径下文件是", f1)
# os.remove(f1)
#
#
# data = xlrd.open_workbook(unicode(r"rv_log.xls",‘utf-8‘)) # 读取路径文件,注意python2需要对中文路径加对应的编码格式
# #data = xlrd.open_workbook(r"E:\*******\项目文件\每周发布服务汇总\20190419\rv_log.xls",‘utf-8‘)
# table = data.sheet_by_index(0)
# nrows = table.nrows #
#
# wbook = copy(data)
# wsheet = wbook.get_sheet(0)
# # 为了写入excle的格式为日期格式
# dateFormat = xlwt.XFStyle()
# dateFormat.num_format_str = ‘yyyy/mm/dd‘
# j = 0;
# for i in range(1, nrows):
# # 获取第7列单元格的信息
# rowValues = table.cell(i, 1).value # 从第0行开始数起
# print( rowValues)
# rm_log(rowValues)
#=======================================================================================20190521==============================================================
注意需要在指定目录上文件夹上面设置对应的excle路径文件
标签:编码格式 font lob utf-8 ftime txt time() xls enc
原文地址:https://www.cnblogs.com/fengyiru6369/p/10901536.html