私は本当に単純なコードを持っていますが、何らかの理由でErr no 2が表示されます。コードは次のとおりです。
import os, shutil
src=r"C:/Documents and Settings/user/Desktop/FilesPy"
des=r"C:/Documents and Settings/user/Desktop/tryPy/Output"
srcFile=r"C:/Documents and Settings/user/Desktop/tryPy/Input/FilesToCopy.txt"
srcFile=open(srcFile,'a+')
for line in srcFile:
name=line.rstrip()
pathS=os.path.join(src,name)
pathD=os.path.join(des,name)
if os.path.exists(pathS):
shutil.copy(pathS,des)
else:
print 'false' + path
しかし、私が得るのは:
IOError: [Errno 2] No such file or directory: 'C:/Documents and Settings/user/Desktop/tryPy/Output\\blatwo.docx'
ネット全体を再検索してみましたが、答えが得られませんでした。助けてください。
ありがとう :)
編集: Eclipseでの実行の完全なトレースは次のとおりです:
pydev debugger
Traceback (most recent call last):
File "D:\EasyEclipse-for-Python-1.3.1\plugins\org.python.pydev.debug_1.3.13\pysrc\pydevd.py", line 803, in <module>
debugger.run(setup['file'], None, None)
File "D:\EasyEclipse-for-Python-1.3.1\plugins\org.python.pydev.debug_1.3.13\pysrc\pydevd.py", line 655, in run
execfile(file, globals, locals) #execute the script
File "D:\Python\CopyChosenFiles\Copy of CopyFiles.py", line 16, in <module>
shutil.copy2(pathS,pathD)
File "C:\Python27\Lib\shutil.py", line 128, in copy2
copyfile(src, dst)
File "C:\Python27\Lib\shutil.py", line 83, in copyfile
with open(dst, 'rb') as fdst:
IOError: [Errno 2] No such file or directory: 'C:/Documents and Settings/user/Desktop/tryPy/Output\\blatwo.docx'
Exception AttributeError: "'NoneType' object has no attribute 'print_exc'" in <function _remove at 0x00AC52B0> ignored