2011-09-22 10 views
12

को कॉपी कर रहा हूँ मैं दो फ़ोल्डर्स है: में, बाहर - यह नहीं डिस्क डी पर सिस्टम फ़ोल्डर है: - विंडोज 7 आउट होते हैं "myfile.txt" मैं चलाने निम्नलिखित पायथन में कमांड:पायथन। IOError: [errno 13] अनुमति अस्वीकृत: जब मैं फ़ाइल

>>> shutil.copyfile(r"d:\Out\myfile.txt", r"D:\In") 

Traceback (most recent call last): 
    File "<pyshell#39>", line 1, in <module> 
    shutil.copyfile(r"d:\Out\myfile.txt", r"D:\In") 
    File "C:\Python27\lib\shutil.py", line 82, in copyfile 
    with open(dst, 'wb') as fdst: 
IOError: [Errno 13] Permission denied: 'D:\\In' 

समस्या क्या है? ,

shutil.copy(PathOf_SourceFileName.extension,TargetFolderPath) 
+0

को कॉपी एक्सप्लोरर का उपयोग करते हुए मैं करने के लिए फ़ोल्डर –

उत्तर

35

docs पढ़ें

shutil.copyfile("D:\Out\myfile.txt", "D:\In") 
0 का उपयोग करें बजाय

shutil.copyfile(r"d:\Out\myfile.txt", r"D:\In") 

r तर्क फ़ाइल को पढ़ने

+0

में मैंने कोशिश की 'shutil.copy' लेकिन अभी भी myfile.txt की प्रतिलिपि कर सकते हैं के लिए नहीं करने के लिए पारित हो जाता है, एक ही त्रुटि का सामना करना पड़ रहा है। – pyd

-3

अच्छी तरह से questionis वर्ष अजगर 3.6 के नए दर्शक के लिए: shutil.copyfile

उदाहरण के बजाय

shutil.copyfile(src, dst)

Copy the contents (no metadata) of the file named src to a file named dst. dst must be the complete target file name; look at copy() for a copy that accepts a target directory path.

+0

यह उत्तर गलत है। 'r' _raw string_ का प्रतीक है, जिसका अर्थ है कि स्ट्रिंग के अंदर" \ "का शाब्दिक अर्थ है" \ "और उसे बचने की आवश्यकता नहीं है। –

संबंधित मुद्दे