擅长:python、mysql、java
<p>在Excel integer to Python datetime位上:</p>
<p>请注意,有两个Excel日期系统(一个基于1900年1月1日,另一个基于1904年1月1日);有关详细信息,请参见<a href="https://support.microsoft.com/en-us/help/214330/differences-between-the-1900-and-the-1904-date-system-in-excel" rel="nofollow noreferrer">https://support.microsoft.com/en-us/help/214330/differences-between-the-1900-and-the-1904-date-system-in-excel</a>。</p>
<p>还要注意,系统不是基于零的。因此,在1900系统中,1900年1月1日是第一天(而不是第0天)。</p>
<pre><code>import datetime
EXCEL_DATE_SYSTEM_PC=1900
EXCEL_DATE_SYSTEM_MAC=1904
i = 42129 # Excel number for 5-May-2015
d = datetime.date(EXCEL_DATE_SYSTEM_PC, 1, 1) + datetime.timedelta(i-2)
</code></pre>