<p><code>time</code>文档没有提到任何限制,但是<a href="https://docs.python.org/3/library/datetime.html" rel="nofollow noreferrer">^{<cd2>} documentation</a>提到了:</p>
<blockquote>
<p><code>fromtimestamp()</code> may raise <code>OverflowError</code>, if the timestamp is out of the range of values supported by the platform C <code>localtime()</code> or <code>gmtime()</code> functions, and <code>OSError</code> on <code>localtime()</code> or <code>gmtime()</code> failure.</p>
<p>[...]</p>
<p>Naive <code>datetime</code> instances are assumed to represent local time and this method relies on the platform C <code>mktime()</code> function to perform the conversion. Since <code>datetime</code> supports wider range of values than <code>mktime()</code> on many platforms, this method may raise <code>OverflowError</code> for times far in the past or far in the future.</p>
</blockquote>
<p>然后我们去<a href="https://msdn.microsoft.com/en-us/library/bf12f0hc.aspx" rel="nofollow noreferrer">Windows documentation</a>:</p>
<blockquote>
<p><code>_localtime64</code>, which uses the <code>__time64_t</code> structure, allows dates to be expressed up through 23:59:59, December 31, 3000, coordinated universal time (UTC), whereas <code>_localtime32</code> represents dates through 23:59:59 January 18, 2038, UTC.</p>
<p><code>localtime</code> is an inline function which evaluates to <code>_localtime64</code>, and <code>time_t</code> is equivalent to <code>__time64_t</code>. If you need to force the compiler to interpret <code>time_t</code> as the old 32-bit <code>time_t</code>, you can define <code>_USE_32BIT_TIME_T</code>. Doing this will cause <code>localtime</code> to evaluate to <code>_localtime32</code>. This is not recommended because your application may fail after January 18, 2038, and it is not allowed on 64-bit platforms.</p>
</blockquote>
<p>所有与时间相关的函数(包括<code>ctime</code>)都是以相同的方式工作的。因此,在Windows10上,您可以可靠地在时间戳之间转换的最大日期是3000-12-31T23:59:59Z</p>
<p>正在尝试获取独立于平台的最大时间戳<a href="https://stackoverflow.com/q/32045725/476716">is difficult</a>。在</p>