def chose_a_option(option=""): attempts = 0 while True: if attempts >= 2: help_funcs.clear_terminal(2) menu.main_menu() attempts = 0 try: option_input = int(input(colour.blue("Digite uma opção: "))) except (ValueError, TypeError): print(colour.red("Digite um valor correto!")) attempts += 1 continue except (KeyboardInterrupt): print( colour.red( "\nPrograma interrompido pelo usuario. Volte sempre :)")) exit() if option_input not in (1, 2, 3, 4): print(colour.red("Selecione uma opção valida!")) attempts += 1 continue return option_input
#!/bin/python2.7 # -*- coding: utf-8 -*- ### pymm実行メインスクリプト ### import configparser import sys from modules import color from modules import logger from modules import menu reload(sys) sys.setdefaultencoding("utf-8") # ロガー生成 logger = logger.logger() # メインプロセス print '' print color.pycolor.YELLOW + ' Welcome to Python Mail Manager.' + color.pycolor.END print '' menu.main_menu()
from modules.menu import main_menu from modules.cipher import hill_cipher, hill_decrypted from modules.alphabet import getAlphabet from modules.utilities import getRandomKey, getModularMatrix # NOTA: Ejecutar desde main.py if __name__ == "__main__": op = 0 key = [] message = "" while not (op in [6, 9]): op = main_menu(key) if op == 1: key = [] elif op == 2: message = input('Ingrese el mensaje a cifrar : ') print("Tamaño de mensaje : " + str(sys.getsizeof(message)) + " Bytes") print("Cifrando mensaje ...") start = time.time() mes_cipher = hill_cipher(key, message) end = time.time() print("El cifrado ha tardado : " + str(end - start) + " segundos") print('Mensaje cifrado: \n') print(mes_cipher) print('\n')
from modules.menu import main_menu from modules import menu_validation from modules import menu_options from datetime import timedelta from modules import movie from modules import help_funcs menu_option = 5 while menu_option != 4: help_funcs.clear_terminal() main_menu() option_selected = menu_validation.chose_a_option() menu_options.options(option_selected) if option_selected is 4: menu_option = option_selected
import sys # import math import modules.data as data # import modules.mctdo as mctdo # import modules.deviation as deviation import modules.menu as menu import modules.print_data as pd if __name__ == '__main__': finish = False # LOOP FOR FINISHING PROGRAM while (finish == False): request = menu.main_menu() #Check exit menu.check_exit(request) #Record data if (request == 'r' or request == 'R'): # Request for type of variable request_variables = menu.type_of_varible_menu() # Calculations for entered values data.initialize(request_variables) new_entry = False #Collect data sample data.get_data() # LOOP FOR KEEP WORKING WITH SAME SAMPLE while (new_entry == False): # Request for measure to show request = menu.measures_menu() #Check exit