システムWindows 8.1 Python 3.4
繰り返しFileNotFound Errno2を取得し、ディレクトリ内のすべてのファイルをコピーしようとしました。python 3.x shutil.copy FileNotFoundError
import os
import shutil
source = os.listdir("C:\\Users\\Chess\\events\\")
for file in source :
shutil.copy(file, "E:\\events\\")
利回り
FileNotFoundError : [Errno2] No such file or directory 'aerofl03.pgn'.
'aerofl03.pgn'
は、ソースリスト['aerofl03.pgn', ...]
の最初のですが。
for file in source :
if file.endswith('.pgn') :
shutil.copy(file, "E:\\events\\")
同じ結果をコード化
for file in "C:\\Users\\Chess\\events\\" :
マイshutil.copy(sourcefileの、destinationfile)は、個々のファイルのコピーを正常に動作している場合:行が追加された場合 同じ結果。
ファイルの値を確認し、完全なパスが含まれていることを確認します – Brody