2012-09-09 4 views
-3

파이썬에서 파일을 복사하여 다른 디렉토리로 옮기는 가장 좋은 방법은 무엇입니까? 이미 존재하는 경우 목적지의 파일을 덮어 쓰시겠습니까? 당신이 '여기에 삽입 디렉토리'를를 사용 하듯이파이썬에서 파일 복사 및 이동?

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

그런 다음 변수 디렉토리를 사용 : 디렉토리 중 하나가 그들에 공백이 할 경우

+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) 

에서보세요 .