Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.01 KB | None | 0 0
  1. # -*- coding:Latin-1 -*
  2.  
  3. # Importer les module utilisé
  4.  
  5. import os
  6. import json
  7. import subprocess
  8.  
  9. # Détection des chemin
  10.  
  11. dossier_courant = os.path.dirname(__file__)
  12. chemin_dictionnaire = os.path.join(dossier_courant, "connexion.json")
  13.  
  14. # Création du dictionnaire
  15.  
  16. if os.path.exists(chemin_dictionnaire):
  17.     with open(chemin_dictionnaire, "r") as f:
  18.         dictionnaire_connexion = json.load(f)
  19.  
  20. else:
  21.     dictionnaire_connexion = {}
  22.  
  23. # Création de l'affichage
  24.  
  25. affichage = """
  26.  
  27. \t1:Connexion
  28. \t2:Inscription
  29. \t3:Sauvegarder votre inscription
  30. \t4:Terminer
  31. """
  32.  
  33. option = "0"
  34.  
  35. while option != "4":
  36.     option = input(affichage)
  37.  
  38.     if option == "1":
  39.         nom = input("Quel est votre nom ? : ")
  40.         prenom = input("Quel est votre prénom ? : ")
  41.         mdp = input("Quel est votre mot de passe ? : ")
  42.  
  43.         if mdp == dictionnaire_connexion[nom + prenom]:
  44.             print("vous ete maintenant connecter ! ")
  45.  
  46.             affichage2 = """
  47.            
  48.            \t1: Ouvrir liste de course
  49.            \t2: quitter
  50.            """
  51.             option2 = "0"
  52.  
  53.             while option2 != "2":
  54.                 option2 = input(affichage2)
  55.                 if option2 == "1":
  56.                     chemin_liste = "C:/Users/bastien/Documents/projet python/formation udemy/TP_liste de course.py"
  57.                     chemin_python = "C:/Users/bastien/AppData/Local/Programs/Python/Python37/python.exe"
  58.                     subprocess.run(chemin_liste, shell=True, check=True)
  59.  
  60.         else:
  61.             print("Vous n'ete pas enregistré ")
  62.  
  63.     elif option == "2":
  64.         nom = input("Quel est votre nom ? : ")
  65.         prenom = input("Quel est votre prénom ? : ")
  66.         mdp = input("Quel est votre mot de passe ? : ")
  67.  
  68.         dictionnaire_connexion[nom + prenom] = mdp
  69.  
  70.     elif option == "3":
  71.         with open(chemin_dictionnaire, "w") as f:
  72.             json.dump(dictionnaire_connexion, f)
  73.  
  74. with open(chemin_dictionnaire, "w") as f:
  75.     json.dump(dictionnaire_connexion, f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement