今天学习了一下python,主要是作了两个例子,总结了一下涉及到的概念。
先把写的例子放上来
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
import re,string
is_all=[]#吧日志一条条分割
is_only={}#只有session和ip,用字典
is_fina={}#最后的结果
def is_find():#主要是用来得到is_all
f=open('D:\\doc\\serachlog.txt','r')
temp=f.readlines()
for line in temp:
is_all.append(re.split('\s\s+|\t|,',line.strip()))
def is_list(ip_all):
for i in range(len(ip_all)):
is_only[ip_all[i][1]]=is_only[i][2]
def is_select(ip_only):
count=0
for values in ip_only.values():
for eachkey in ip_only.keys():
if values==ip_only[eachkey]:
count=count+1
is_final[values]=count
count=0