python中判断readline读到文件末尾
fp = open(‘somefile.txt‘)
while True:
line = fp.readline()
if not line:
break
Python中,空串的not返回true,即not line时为读到EOF(文件末尾)
文章来自:http://www.cnblogs.com/summerkiki/p/4472043.html
fp = open(‘somefile.txt‘)
while True:
line = fp.readline()
if not line:
break
Python中,空串的not返回true,即not line时为读到EOF(文件末尾)