From 16c1ae7e44116ee55e098f9e98f7e1566d41eca2 Mon Sep 17 00:00:00 2001 From: Johan Largy Date: Thu, 29 Sep 2022 09:27:08 +0200 Subject: [PATCH] script python --- sio2/sisr2/30-Python/Exo4 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 sio2/sisr2/30-Python/Exo4 diff --git a/sio2/sisr2/30-Python/Exo4 b/sio2/sisr2/30-Python/Exo4 new file mode 100644 index 0000000..5185b91 --- /dev/null +++ b/sio2/sisr2/30-Python/Exo4 @@ -0,0 +1,29 @@ +#!/usr/bin/python3 + +import sys + +#print ("Nom du programme : ", sys.argv[0]) +#print ("Nombre d'arguments: ", len(sys.argv)) +#print ("Les arguments sont : " , str(sys.argv)) + +if len(sys.argv) != 2: + msg= ("Usage : " + sys.argv[0] + " ") + print(msg ,file=sys.stderr) + sys.exit(1) + +filename = sys.argv[1] +try: + file= open(filename , "r") +except: + msg = ("Erreur ouverture fichier " + filename) + print(msg ,file=sys.stderr) + +else: + line = file.readline() + linee = line.rstrip() + while linee: + (login, complet) = linee.split(":") + print (login, " ",complet) + line = file.readline() + linee = line.rstrip() + file.close()