Python Regular Expression to Match the Whole line

前端 未结 3 1562
天命终不由人
天命终不由人 2021-01-13 12:21

I\'m new to scripting and have been reading about how to use regular expressions.

I want to fetch the complete line matching a pattern.

my ouptut is:

3条回答
  •  佛祖请我去吃肉
    2021-01-13 12:43

    If you want to print the whole line you can just iterate through the lines and print those that contain 'packet loss'.

    for line in lines:
        if line.find('packet loss') != -1:
            print line
    

提交回复
热议问题