python-xlrd读取excel的类型为日期时间

 1、excel内容  时间、日期、字符串、数字

#行rows 列cols
for
row in range(0, table.nrows): for col in range(0,table.ncols): if table.cell(row, col).ctype == 3: import datetime from xlrd import xldate_as_tuple date = xldate_as_tuple(table.cell(row, col).value, 0) print(datetime.datetime(*date)) #将时间转字符串

out:

[['time'], [44114.7423611111], [44114.0], ['2020/10/10'], [20201010.0]]
2020-10-10 17:49:00
2020-10-10 00:00:00

原文地址:https://www.cnblogs.com/shuzf/p/13794232.html