我在下面的代码中得到一个错误,上面写着:FileNotFoundError: [WinError 2] The system cannot find the file specified: 'Harry White.txt' -> 'C:\\Users\\johna\\Desktop\\z_testingmove\\Harry White\\Harry White.txt'
有人能帮我吗
import shutil
import os, sys
source = 'C:\\Users\\johna\\Desktop\\z_testingmove'
dest1 = 'C:\\Users\\johna\\Desktop\\z_testingmove\\Harry White'
dest2 = 'C:\\Users\\johna\\Desktop\\z_testingmove\\John Smith'
dest3 = 'C:\\Users\\johna\\Desktop\\z_testingmove\\Judy Jones'
files = os.listdir(source)
for f in files:
if f == "Harry White.txt":
shutil.move(f, dest1)
elif f == "John Smith.txt":
shutil.move(f, dest2)
elif f == "Judy Jones.txt":
shutil.move(f, dest3)
您错误地理解了
shutil.move
函数The
shutil.move(src, dst)
文件或目录的
src
和dst
必须是full path
。您必须更改代码,请尝试以下操作:
相关问题 更多 >
编程相关推荐