noob: print and file.read()

Andrew Z formisc at gmail.com
Mon Dec 3 18:06:43 EST 2012


Hello,
 why the following code doesn't print the content of the file:
#!/usr/bin/python

from_file ="file.txt"
in_file = open(from_file)
str = in_file.read()
print "Here should be the output from the file - ", in_file.read()
print "Here should be the output from the STR- ", str in_file.close()


The first "print" has nothing whereas the second properly displays the
content of the file.

Thank you
AZ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121203/e6dddf93/attachment.html>


More information about the Python-list mailing list