SoFunction
Updated on 2024-11-17

For a detailed explanation of python xlrd's method of reading datetime type data

The time field read out using xlrd is a floating point number similar to 41410.5083333, which needs to be converted to the corresponding datetime type when used, and the following code is the conversion method:

First you need to introduce the xldate_as_tuple function

from xlrd import xldate_as_tuple

The method of use is as follows:

#d is a floating-point number read from excel.

xldate_as_tuple(d,0)

The second argument to xldate_as_tuple has two values, 0 or 1. 0 is the date based on 1900-01-01, while 1 is the date based on 1904-01-01. The function returns a tuple whose values are similar to: (year, month, day, hour, minute, nearest_second)

Above this on python xlrd read datetime type data method details is all I share with you, I hope to give you a reference, and I hope you support me more.