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