Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.python
Re: read files
Alex Ezell
1/22/2008 3:07:00 AM
You might could do one of these two methods:
fd.readlines()
or:
for line in fd:
print line
These are both from the Python tutorial found here:
http://docs.python.org/tut/node9.html#SECTION00921000000...
/alex
On Jan 21, 2008 9:00 PM, J. Peng <jpeng@block.duxieweb.com> wrote:
> first I know this is the correct method to read and print a file:
>
> fd = open("/etc/sysctl.conf")
> done=0
> while not done:
> line = fd.readline()
> if line == '':
> done = 1
> else:
> print line,
>
> fd.close()
>
>
> I dont like that flag of "done",then I tried to re-write it as:
>
> fd = open("/etc/sysctl.conf")
> while line = fd.readline():
> print line,
> fd.close()
>
>
> this can't work.why?
> --
>
http://mail.python.org/mailman/listinfo/p...
>
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: read files
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password