python中判断readline读到文件末尾
时间:2015-05-02 16:33:10
收藏:0
阅读:2603
fp = open(‘somefile.txt‘)
while True:
line = fp.readline()
if not line:
break
Python中,空串的not返回true,即not line时为读到EOF(文件末尾)
评论(0)