reading and writing files
Adrián Monkas
adrian.monkas at bqn.com.uy
Tue Aug 23 15:00:26 EDT 2011
Hi.
I`ve been trying to copy a long text from one file to another but it always
copied me just a small part.
I would be glad if you can help me or explain which is my error.
Thanks
----------------------------------------------------------------------------------
def runMenu():
print "\nMENU"
print " 1) Copiar"
print " 0) Exit"
response = int( raw_input().strip() )
if response == 1:
print "Copiar"
try:
print "Abro Archivo Origen"
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)
print "Abro Archivo Destino"
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()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110823/dd321da3/attachment.html>
More information about the Python-list
mailing list