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.
将python中的文件复制和移动到不同目录并覆盖目标中的这些文件(如果它们已经存在)的最佳方法是什么?
看看shutil.copyfile
file1=open('insert directory here').readlines() file2=open('insert directory here', 'w') file2.write(file1)
如果任一目录中有空格,请执行以下操作:
directory='insert directory here' directory=directory.rstrip()
然后像使用“在此处插入目录”一样使用变量目录。