Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果文件夹 2 不包含文件,我需要编写 python 代码将文件从一个文件夹(文件夹 1)移动到另一个文件夹(文件夹 2)。我想知道我们是否应该使用 shutil.copy
试试这个
if not os.path.exists('destination path'): shutil.move("path/to/current/file.foo", "path/to/new/destination/for/file.foo")