1. 程式人生 > >找出文本中特定字符串的整行腳本

找出文本中特定字符串的整行腳本

python

#!/bin/env python
#-*- coding:utf-8 -*-
import os
import sys
from subprocess import Popen
#__author__ = huangyishan

def main():
    special_string = ‘42.120.63.223‘
    txt_content = open(‘skysrt.txt‘,‘r‘)
    for line in txt_content.readlines():
        l = line.strip()
        if l.find(special_string)>=0:
            print(l)

if __name__ == ‘__main__‘:
    main()





///

本文出自 “黃怡善的運維博客” 博客,謝絕轉載!

找出文本中特定字符串的整行腳本