#!/usr/local/bin/python3 # -*- coding: utf8 -*- import sys from datetime import date from xlrd import open_workbook from xlwt import Workbook from xlrd import xldate_as_tuple input_file = sys.argv[1] output_file = sys.argv[2] output_workbook = Workbook() output_worksheet = output_workbook.add_sheet('jan_2013_output') with open_workbook(input_file) as workbook: worksheet = workbook.sheet_by_name('January_2013') for row_index in range(worksheet.nrows): row_list_output = [] for col_index in range(worksheet.ncols): if worksheet.cell_type(row_index, col_index) == 3: date_cell = xldate_as_tuple(worksheet.cell_value(row_index, col_index), workbook.datemode) date_cell = date(*date_cell[0:3]).strftime('%m-%d--%Y') #print("{33}") #print(date_cell) row_list_output.append(date_cell) o
Python3 利用xlrd 处理excel中的日期的格式
最新推荐文章于 2024-05-24 07:30:00 发布