<p>在Python中,我们如何计算一年中的日历周数?在</p>
<p>我在标准库中找不到函数。在</p>
<p>然后我考虑了<code>date(year, 12, 31).isocalendar()[1]</code>,但是</p>
<blockquote>
<p>For example, 2004 begins on a Thursday, so the first week of ISO year 2004 begins on Monday, 29 Dec 2003 and ends on Sunday, 4 Jan 2004, so that <code>date(2003, 12, 29).isocalendar() == (2004, 1, 1)</code> and <code>date(2004, 1, 4).isocalendar() == (2004, 1, 7)</code>.</p>
</blockquote>