Reputation: 161
I am trying to open a file but it is displaying nothing.
openf = open('C:\Python27\NEWS', 'r')
openf.read()
It is neither displaying text nor any error. What could be the reason?
and when i write like this
openf = open('C:\Users\K\Desktop\wait.txt', 'r')
>>> print openf
This gives Output:
<open file 'C:\\Users\\K\\Desktop\\wai.txt', mode 'r' at 0x0000000002B4DDB0>
What does this mean?
Upvotes: 0
Views: 1522
Reputation: 76194
read
doesn't display anything - it merely returns a string. If you're not at an interactive prompt, the only output you will see is what you print.
openf = open('C:\Python27\NEWS', 'r')
print openf.read()
print openf
will give details about the openf
object. It's an open file pointed at that file name, it was opened in "read" mode, and it exists in memory at address 0x0000000002B4DDB0.
Upvotes: 1