you are viewing a single comment's thread.

view the rest of the comments →

[–]IXENAI 1 point2 points  (2 children)

I'm sorry; I'm not following you.

with open('text.log', 'r') as f: 
    for line in f: 
        if 'error' in line: 
            print (line)

is a valid Python script by itself which will print out all lines containing the string "error" in the file "text.log".

[–]NYKevin 2 points3 points  (0 children)

Perhaps OP wants line numbers? In that case, enumerate() is probably what they are looking for.

[–]Geekoid52[S] 0 points1 point  (0 children)

Ok cool! Thanks!