搜尋此網誌

2013年3月22日 星期五

How to USE python to find out /etc/hosts ip

import os,re tt2=open('/etc/hosts','r')
for s in tt2: #ip hostname pattern as \d+.\d+.\d+.\d \d means number
     matchObj = re.match( r'\d+.\d+.\d+.\d+\t\w+',s)
        if matchObj:
           print "matchObj.group() : "matchObj.group().split('\t')

沒有留言: