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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | import time from colorama import Fore, Style opc = 1 while opc != 4: print ( Fore.CYAN + "\t\tMENU\n\n1.- Capturar nuevo registro\n2.- Mostrar registros\n3.- Eliminar registro\n4.- Salir" + Style.RESET_ALL) opcion = raw_input("Elige la opcion:\n") if opcion == "1": op = "si" x = 0 while op != "no": rc = "no" while rc != "si": print (Fore.BLUE + "\t\tNUEVO REGISTRO\n" + Style.RESET_ALL) archivo = open("Ejemplo.csv", "a") nombre = raw_input("Ingresa un nombre:\n") apellido = raw_input("Ingresa un apellido\n") print ( Fore.BLUE + "\t\tEL REGISTRO INGRESADO ES : " + nombre + " " + apellido + "\n\t\tES CORRECTO? si/no\n" + Style.RESET_ALL) rc = raw_input() while x != 1: if rc != "si" and rc != "no": print (Fore.RED + "\t\tINGRESE UNA RESPUESTA CORRECTA si/no\n" + Style.RESET_ALL) rc = raw_input() else: x = 1 if rc == "si": rc = "si" else: rc = "no" print (Fore.RED + "\t\tSE A CAPTURADO EL REGISTRO : " + Style.RESET_ALL + nombre + " " + apellido) archivo.write(nombre + "," + apellido + "\n") print (Fore.BLUE + "\t\tREQUIERE INGRESAR OTRO REGISTRO? si/no" + Style.RESET_ALL) op = raw_input() elif opcion == "2": print (Fore.GREEN + "\t\tMOSTRAR REGISTROS\n" + Style.RESET_ALL) archivo = open("Ejemplo.csv") r = archivo.read() if r == "": print (Fore.RED + "\t\tEL ARCHIVO ESTA VACIO\n\n") archivo.close() time.sleep(3) else: print "Cargando.." time.sleep(2) print (Fore.GREEN + "Carga lista:" + Style.RESET_ALL) print r archivo.close() time.sleep(3) elif opcion == "3": print Fore.RED + "\t\tBORRAR\n" archivo = open("Ejemplo.csv", "a") a = open("Ejemplo.csv") r = a.read() if r == "": print ("\t\tEL ARCHIVO ESTA VACIO\n\n") archivo.close() time.sleep(3) else: archivo.truncate() print (Fore.RED + "\t\tLOS REGISTROS HAN SIDO BORRADOS\n" + Style.RESET_ALL) archivo.close() time.sleep(3) elif opcion == "4": print (Fore.RED + "\t\tSALIR DEL PROGRAMA") print ("\t\tADIOS" + Style.RESET_ALL) opc = 4 |
lunes, 12 de noviembre de 2018
Programa de lyvan colorama
Suscribirse a:
Comentarios de la entrada (Atom)
No hay comentarios.:
Publicar un comentario