[Tutor] how to get a line text from input file.
Kent Johnson
kent37 at tds.net
Wed Mar 22 04:20:06 CET 2006
Keo Sophon wrote:
> Hi all,
>
> i am new to programming language and python. I wonder how to get a line text
> from input file.
The simplest Python idiom to do something with each line of a file is this:
for line in open('somefile.txt'):
# do something with line
You can find out more here:
http://docs.python.org/tut/node9.html#SECTION009200000000000000000
Kent
More information about the Tutor
mailing list