missed a parenthesis, it should look like - with open(<filepath>, <mode>) as <filehandle>: <indent>//operation with the file.
On Wed, Jan 30, 2013 at 12:31 PM, <[email protected]> wrote: > A safer approach would be - > with open(<filepath>, <mode> as <filehandle>: > <indent>//operation with the file. > > This way, you do not have to remember to close the file explicitly. > > > On Wed, Jan 30, 2013 at 12:27 PM, Dave Angel <[email protected]> wrote: > >> On 01/30/2013 01:51 AM, Gayathri S wrote: >> >>> Hi All....! >>> I don't know how to read text file in python. If the >>> data >>> values are stored in a text file format, for >>> example(1,30,60,90,120...200) >>> means what i would do for reading it in python. could you just explain >>> it. >>> >>> >>> >> infile = open("filename", "rt") will open a text file >> >> line = infile.readline() will read one line from it, as a str >> >> After that, you can parse it anyway you like. >> >> >> >> >> -- >> DaveA >> ______________________________**_________________ >> Tutor maillist - [email protected] >> To unsubscribe or change subscription options: >> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor> >> > > > > -- > http://spawgi.wordpress.com > We can do it and do it better. > -- http://spawgi.wordpress.com We can do it and do it better.
_______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
