-1

如果文件夹 2 不包含文件,我需要编写 python 代码将文件从一个文件夹(文件夹 1)移动到另一个文件夹(文件夹 2)。我想知道我们是否应该使用 shutil.copy

4

1 回答 1

1

试试这个

if not os.path.exists('destination path'):
    shutil.move("path/to/current/file.foo",
                "path/to/new/destination/for/file.foo")
于 2017-08-04T22:38:16.087 回答