Nouvelle version du dimanche
This commit is contained in:
@@ -5,10 +5,23 @@ _repertoire = {
|
||||
"Bob": "0600000002"
|
||||
}
|
||||
|
||||
def lecture():
|
||||
with open('repertoire.txt','r') as f:
|
||||
for ligne in f:
|
||||
ligne = ligne.replace("\n","")
|
||||
nom,numero=list(ligne.split(";;"))
|
||||
_repertoire[nom]=numero
|
||||
return _repertoire
|
||||
|
||||
|
||||
def rechercher(nom: str) -> str:
|
||||
"""Renvoie le numéro si le nom existe, sinon 'Inconnu'."""
|
||||
return _repertoire.get(nom, "Inconnu")
|
||||
|
||||
def ajouter(nom: str, numero: str) -> None:
|
||||
"""Ajoute ou remplace une entrée du répertoire."""
|
||||
_repertoire[nom] = numero
|
||||
with open('repertoire.txt','a') as f :
|
||||
f.write(nom)
|
||||
f.write(';;')
|
||||
f.write(numero)
|
||||
f.write("\n")
|
||||
|
||||
Reference in New Issue
Block a user