擅长:python、mysql、java
<p>如果我不得不猜测,你做到了:</p>
<pre><code>import datetime
</code></pre>
<p>在代码的顶端。这意味着您必须这样做:</p>
<pre><code>datetime.datetime.strptime(date, "%Y-%m-%d")
</code></pre>
<p>访问<code>strptime</code>方法。或者,您可以将import语句更改为:</p>
<pre><code>from datetime import datetime
</code></pre>
<p>照你现在的样子去看。</p>
<p>制造<a href="https://docs.python.org/3/library/datetime.html" rel="noreferrer">^{<cd2>} module</a>的人也将他们的<a href="https://docs.python.org/3/library/datetime.html#available-types" rel="noreferrer">class ^{<cd2>}</a>命名为:</p>
<pre><code>#module class method
datetime.datetime.strptime(date, "%Y-%m-%d")
</code></pre>