Skip to main content
 首页 » 编程设计

python之shutil.move -> WindowsError : [Error32] The process cannot access the file

2025年05月04日20insus

我使用 Python 2.5。 shutil.move 有问题

print(srcFile) 
print(dstFile) 
shutil.move(srcFile, dstFile) 

输出:

c:\docume~1\aaa\locals~1\temp\3\tmpnw-sgp 
D:\dirtest\d\c\test.txt 
... 
WindowsError: [Error32] The process cannot access the file because it is being used by  
  another process: 'c:\\docume~1\\aaa\\locals~1\\temp\\3\\tmpnw-sgp' 

我在 Windows 2003 Server 上使用它。

那么,这里出了什么问题?有人知道吗?

最好的问候。

请您参考如下方法:

如果你想继续你的脚本使用:

try: 
    shutil.move(srcFile, dstFile) 
except WindowsError: 
    pass 

您收到错误 32 的原因是您的计算机或服务器上有另一个进程正在使用该文件。您可能不想复制临时文件,因为它们的名称并不重要。