2013-05-14 106 views
1

我使用下面的代碼一個目錄中的內容複製到另一個目錄(蟒蛇)Python不能創建文件錯誤[錯誤:183]

shutil.copytree(sourceDirectory,destinationDirectory,symlinks=False,ignore=ignore_patterns(updatedList)) 

其中

updatedList =, (根據用戶輸入)的.config, .ICO,*。登錄

我生成的飛行這updatedList 但是,每當我嘗試執行上述的複製操作時,我都會收到以下錯誤消息。

[錯誤183]無法創建一個文件時,該文件已存在

注意:會有一些文件存在於匹配的updatedList提到的擴展的源目錄。

我在想,提及已經存在於忽略列表中的文件的擴展應該就足夠了,但顯然它沒有。

我目前正在使用Python 2.7

我進口

import logging 
import os 
from win32api import GetFileVersionInfo, LOWORD, HIWORD 
import zipfile 
import shutil 
import sys 
from os.path import isfile 
from distutils import dir_util 
import ConfigDTO 
import datetime 
import UpdateSettings 
import time 
import win32api 
import socket 
from shutil import copytree, ignore_patterns 
import os 

請幫助。

謝謝

+0

什麼'updatedList'真正定義?你在那裏的例子是無效的語法。 – bernie 2013-05-14 17:38:01

+0

如果你顯示你的'import'語句,它可能也會有所幫助。 – bernie 2013-05-14 17:38:56

+0

@bernie,updatedList定義如下:updatedList ='' – Gagan 2013-05-14 17:40:28

回答

1

我明白了..抱歉,這是我的錯。 shutil的文檔特別指出目標目錄不能存在。在我的情況下,目的地目錄存在更早,因此我得到的消息。

感謝

more information here