2012-09-09 85 views
-3

将python中的文件复制和移动到其他目录的最佳方式是什么?如果它们已经存在,覆盖目标文件中的那些文件?在Python中复制和移动文件?

+8

已经[问](http://stackoverflow.com/questions/123198/how-do-i-copy-a-file-in-python)? – Onlyjus

回答

0
file1=open('insert directory here').readlines() 
file2=open('insert directory here', 'w') 
file2.write(file1) 

如果两个目录都在他们的空间做到这一点:

directory='insert directory here' 
directory=directory.rstrip() 

然后使用该变量的目录,你会“在此插入目录”使用。