2012-09-09 84 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() 

然後使用該變量的目錄,你會「在此插入目錄」使用。