Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
45a25f53be | |||
189080c510 |
15
sio2/sisr/20-python/cptmot.py
Normal file
15
sio2/sisr/20-python/cptmot.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/lib/python3
|
||||||
|
|
||||||
|
phrase = input('Phrase : ')
|
||||||
|
tabmot = phrase.split(' ')
|
||||||
|
cptmot = {}
|
||||||
|
|
||||||
|
for mot in tabmot :
|
||||||
|
if mot in cptmot :
|
||||||
|
cptmot[mot] = cptmot[mot] + 1
|
||||||
|
else :
|
||||||
|
cptmot[mot] = 1
|
||||||
|
|
||||||
|
for key in cptmot.keys() :
|
||||||
|
print (key, " ", cptmot[key])
|
||||||
|
|
22
sio2/sisr/20-python/log.py
Normal file
22
sio2/sisr/20-python/log.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#/usr/bien/python3
|
||||||
|
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
cptip = {}
|
||||||
|
regexp = '^(\S+) (\S+) (\S+) \[([^]]+)\] "(\w+) (\S+).*" (\d+) (\S+)'
|
||||||
|
|
||||||
|
for line in sys.stdin :
|
||||||
|
line = line.rstrip ()
|
||||||
|
match = re.match (regexp, line)
|
||||||
|
if match :
|
||||||
|
print (match.group(1)," ",match.group(8))
|
||||||
|
ip = match.group(1)
|
||||||
|
vol = int(match.group(8))
|
||||||
|
if ip in cptip :
|
||||||
|
cptip[ip] = cptip[ip] + vol
|
||||||
|
else:
|
||||||
|
cptip[ip] = vol
|
||||||
|
|
||||||
|
for key in cptip.keys():
|
||||||
|
print(key, ":", cptip[key])
|
Loading…
x
Reference in New Issue
Block a user