f = open("latex.log")
s = 0
for line in f:
line = line.strip('\n')
if len(line) == 0:
continue
s += 1
print("共{}行".format(s))
为什么不用read?
这样遍历文件是遍历文件每一个字符还是每一行遍历?为什么?
strip函数是做什么的?
f = open("latex.log")
s = 0
for line in f:
line = line.strip('\n')
if len(line) == 0:
continue
s += 1
print("共{}行".format(s))
为什么不用read?
这样遍历文件是遍历文件每一个字符还是每一行遍历?为什么?
strip函数是做什么的?