noob: print and file.read()

A

Andrew Z

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top