<p>您可以直接从datetime获取周数作为字符串。</p>
<pre><code>>>> import datetime
>>> datetime.date(2010, 6, 16).strftime("%V")
'24'
</code></pre>
<p>此外,您还可以通过更改<code>strftime</code>参数获得一年中周数的不同“类型”:</p>
<blockquote>
<p><code>%U</code> - <strong>Week number of the year (Sunday as the first day of the week)</strong> as a zero padded decimal number. All days in a new year preceding the first Sunday are considered to be in week 0. Examples: <strong>00</strong>, 01, …, 53</p>
<p><code>%W</code> - Week number of the year (<strong>Monday</strong> as the first day of the week) as a decimal number. All days in a new year preceding the first Monday are considered to be in week 0. Examples: <strong>00</strong>, 01, …, 53</p>
<p>[...]</p>
<p>(<em>Added in Python 3.6, backported to some distribution's Python 2.7's</em>) Several additional directives not required by the C89 standard are included for convenience. These parameters all correspond to ISO 8601 date values. <strong>These may not be available on all platforms when used with the <code>strftime()</code> method.</strong> </p>
<p>[...]</p>
<p><code>%V</code> - <strong>ISO 8601 week</strong> as a decimal number with Monday as the first day of the week. Week 01 is the week containing Jan 4. Examples: <strong>01</strong>, 02, …, 53</p>
<p>from: <a href="https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior" rel="noreferrer">datetime — Basic date and time types — Python 3.7.3 documentation</a></p>
</blockquote>
<p>我是从<a href="http://www.tutorialspoint.com/python/time_strftime.htm" rel="noreferrer">here</a>那里知道的。它在Python 2.7.6中对我有效</p>