한 파일에서 다른 파일로 긴 텍스트를 복사하려고 시도했지만 항상 작은 부분 만 복사했습니다. 그것은 내가 해결할 수있는 한계 문제처럼 보입니다.파일 읽기/쓰기 문제
누구든지 나를 도울 수 있거나 내 오류를 설명 할 수 있다면 기쁠 것입니다.
def runMenu():
print "\nMENU"
print " 1) Copiar"
print " 0) Exit"
response = int(raw_input().strip())
if response == 1:
print "Copiar"
try:
archivo=open("D:\Boot.txt","r")
print "Name of the file: ", archivo.name
print "Closed or not : ", archivo.closed
print "Opening mode : ", archivo.mode
print "--------ORIGEN-----------"
print archivo.read()
print "-------------------------"
archivo.seek(0, 0)
archivo2=open("D:\Copia.txt","w+")
print "Name of the file: ", archivo2.name
print "Closed or not : ", archivo2.closed
print "Opening mode : ", archivo2.mode
archivo2.write(archivo.read())
archivo2.seek(0, 0)
print "---------DESTINO---------"
print archivo2.read()
print "-------------------------"
archivo.close()
archivo2.close()
except IOError:
print ("I/O Error de Lectura")
else:
print "Lectura OK"
elif response == 0:
#device.close()
print "Exit"
return response
def main():
print "main"
while(1):
if runMenu() == 0: break
main()
귀하의 질문에 직접적인 대답은 아니지만, 아무 것도 수정하지 않고 파일을 새로운 위치로 복사하려는 경우 [다음] (http://docs.python.org/library/shutil)을 보았습니까? .html # directory-and-files-operations) 방법? 그들은 당신을 위해 모든 일을해야합니다. –
및 복사 할 파일의 크기는 무엇입니까 –