From b82576d49e201814f0552a874ce6cdb1962fc473 Mon Sep 17 00:00:00 2001 From: ludo Date: Wed, 6 Oct 2021 09:32:17 +0200 Subject: [PATCH] python2 --- sio2/sisr/20-python/cptmot.py | 13 +++++++++++++ sio2/sisr/20-python/log.py | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100755 sio2/sisr/20-python/cptmot.py create mode 100755 sio2/sisr/20-python/log.py diff --git a/sio2/sisr/20-python/cptmot.py b/sio2/sisr/20-python/cptmot.py new file mode 100755 index 0000000..8120f12 --- /dev/null +++ b/sio2/sisr/20-python/cptmot.py @@ -0,0 +1,13 @@ +#!/usr/bin/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]) diff --git a/sio2/sisr/20-python/log.py b/sio2/sisr/20-python/log.py new file mode 100755 index 0000000..50747d9 --- /dev/null +++ b/sio2/sisr/20-python/log.py @@ -0,0 +1,10 @@ +#!/bin/usr/python3 +import re +import sys +group = {} +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))