noob: print and file.read()

Andrew Z formisc at gmail.com
Tue Dec 4 00:06:43 CET 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