reading and writing files

Muresan Alexandru Mihai muresanalex.contact at gmail.com
Wed Aug 24 02:29:41 EDT 2011


If you need an int isn't better to use input() instead of raw_input() ?

On Tue, Aug 23, 2011 at 10:00 PM, Adrián Monkas <adrian.monkas at bqn.com.uy>wrote:

> 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()
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>


-- 
Muresan Alexandru
Web Developer
0740782921
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110824/eac2dc86/attachment-0001.html>


More information about the Python-list mailing list