<p>当我使用python文档(<a href="https://docs.python.org/3/library/os.html#os.scandir" rel="noreferrer">here</a>)中的示例代码时,会引发一个<code>AttributeError</code>。示例代码如下:</p>
<pre><code>with os.scandir(path) as it:
for entry in it:
if not entry.name.startswith('.') and entry.is_file():
print(entry.name)
</code></pre>
<p>结果是<code>AttributeError</code>:</p>
^{pr2}$
<p>不过,将<code>os.scandir()</code>分配给变量可以正常工作。
有人能告诉我我缺少什么吗?在</p>