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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM