python - Count the line number of file -
i want count file lines.
i have googoled around , found 2 ways in vane
test = open('./log/test.csv','a') if sum(1 line in test) == 0: print("no line") shows
io.unsupportedoperation: not readable second way
test = open('./log/test.csv','a') if len(test.readlines()) == 0: print("no line") it shows error too.
try doing:
test = open('./log/test.csv', 'r') the issue don't have on read mode
Comments
Post a Comment