尝试使用shutil

时间:2017-03-28 12:13:14

标签: python shutil

我试图将文件从一个位置复制到另一个位置。所以我这样做:

import shutil
import os
source = os.listdir("C:/Users/Marc/Dropbox/PROJECTEN/Lopend/PianoKing/AssignScores/Final/")
destination = "C:/Users/Marc/Dropbox/PROJECTEN/Lopend/PianoKing/AssignScores/Final/test"

for files in source:
 if files.endswith(".txt"):
  print(files)
  shutil.copy(files,destination)

这表明我有一个位置,但不会复制文件。我收到以下错误:

 File "C:/Users/Marc/contexta-misc-python-scripts/kaldi_corpus/recognize_zip_code.py", line 9, in <module>
 shutil.copy(files,destination)
 File "C:\Users\Marc\Anaconda2\lib\shutil.py", line 119, in copy
 copyfile(src, dst)
 File "C:\Users\Marc\Anaconda2\lib\shutil.py", line 82, in copyfile
 with open(src, 'rb') as fsrc:
 IOError: [Errno 2] No such file or directory: '1.txt'

有关触发此错误的内容的任何想法?

0 个答案:

没有答案