1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| # Créé par AFCHAIL, le 31/01/2022 en Python 3.7
fichier=open('repertoire.txt','w')
fichier.write(" ROSSIGNOL Julien 06.92.25.54.20 \n MAILLOUX Elise 06.77.71.43.58 \n LECLAIR Bernard 06.78.93.92.67 \n DUPLESSIS Joana 06.07.31.92.76 \n LEBRUN Georges 06.85.00.16.97 \n")
fichier.close()
def ajouter(nom, prénom, téléphone):
fichier=open('repertoire.txt','a')
with open('repertoire.txt','a') as f :
f.write(" "+nom+" ")
with open('repertoire.txt','a') as f :
f.write(prénom+" ")
with open('repertoire.txt','a') as f :
f.write(téléphone+"\n")
nom=input("Nom :")
prénom=input("Prénom :")
téléphone=input("Numéro de téléphone :")
ajouter(nom,prénom,téléphone)
def rechercher(repertoire):
fichier=open('repertoire.txt','r')
for ligne in fichier :
if texteRecherché in ligne :
print("Le(s) contact(s) associé est :",ligne)
if texteRecherché not in ligne:
print("Vous n'avez pas de contact correspondant à votre recherche :",texteRecherché )
texteRecherché=input("Entrez le nom, le prénom ou le numéro de téléphone du contact que vous voulez rechercher :")
rechercher(texteRecherché)
def supprimer(contact):
fichier=open('repertoire.txt','r')
for ligne in fichier :
if texteASupprimer in ligne :
texteASupprimer.pop()
if texteRecherché not in ligne:
print("Vous n'avez pas de contact correspondant à votre recherche :",texteASupprimer )
texteASupprimer=input("Entrez le nom, le prénom ou le numéro de téléphone du contact que vous voulez supprimer :")
supprimer(texteASupprimer) |
Partager