【发布时间】:2012-04-13 11:52:08
【问题描述】:
fp = open("a.txt")
#do many things with fp
c = fp.read()
if c is None:
print 'fp is at the eof'
除了上面的方法,还有什么方法可以判断fp是否已经在eof了?
【问题讨论】:
-
打开文件的
withstatement 值得一看 - 它很好地为您处理关闭和异常,并且读起来很好。