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')
沒有留言:
張貼留言