TP python

This commit is contained in:
Votre Nom
2023-10-09 17:11:49 +02:00
parent ce7de1abb0
commit 8b71aef87b
3 changed files with 73 additions and 0 deletions

27
sio2/SISR/Python/analog Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/python3
import sys
import re
#tab = []
volume = {}
regexp = "^(\S+) (\S+) (\S+) \[([^]]+)\] \"(\w+) (\S+).*\" (\d+) (\S+)"
for line in sys.stdin: # on lit sur lentrée standard
line = line.rstrip () # on enleve le retour ligne
res = re.match (regexp, line)
if res:
(host, rfc931, user, date, request, url, status, byte) = res.groups()
host = res.group (1)
byte =int(res.group (8))
if host in volume:
volume[host]= volume[host] + byte
else:
volume[host] = byte
for host in volume.keys():
print(host, ":", volume[host])