%20%E6%8B%8B%E5%87%BA%E5%B1%AC%E6%80%A7%E9%8C%AF%E8%AA%A4.png)
我正在嘗試使用建立臨時目錄with tempfile.TemporaryDirectory() as directory:
我已經導入了臨時文件
當我運行該程式時,我收到錯誤:
Traceback (most recent call last):
File "batch.py", line 79, in <module>
with tempfile.TemporaryDirectory() as directory:
AttributeError: 'module' object has no attribute 'TemporaryDirectory'
我正在運行 python 3.8
如果使用偵錯器運行程式將成功運行,但是當我在不使用偵錯器的情況下運行它時,我會收到此錯誤。
完整程式碼:
with tempfile.TemporaryDirectory() as directory:
for subdir, dirs, files in os.walk(rootdir):
if subdir != rootdir and subdir != fDestination and subdir != meDir
and subdir != fileDestination and subdir != zdir:
shutil.move(subdir, directory)