script python
This commit is contained in:
parent
4850b95120
commit
16c1ae7e44
29
sio2/sisr2/30-Python/Exo4
Normal file
29
sio2/sisr2/30-Python/Exo4
Normal file
@ -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] + " <fichier.txt>")
|
||||
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()
|
Loading…
x
Reference in New Issue
Block a user