Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > noob: print and file.read()

Reply
Thread Tools

noob: print and file.read()

 
 
Andrew Z
Guest
Posts: n/a
 
      12-03-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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
print a vs print '%s' % a vs print '%f' a David Cournapeau Python 0 12-30-2008 03:19 AM
Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working keto Java 0 05-30-2007 11:27 AM
Lock Print Screen and File Print Bryan Shaw ASP .Net 3 04-20-2005 02:54 PM
Print and print overview and current page Bernard Segonnes Java 0 11-04-2004 02:48 PM
Unlarging the print to print using PDF file to print Bun Mui Computer Support 3 09-13-2004 03:15 AM



Advertisments