A
A
Anton Chernyshev2020-06-17 18:20:56
Python
Anton Chernyshev, 2020-06-17 18:20:56

Unable to output data from .txt file. How to implement it?

here is the code

import random

file = open('passwords_dictionary.txt', 'a+')

letters = 'qwertyuiopasdfghjklzxcvbnm'
passwords = {}
while True:
    mod = input('''введите 1 для генерации пароля
введите 2 для поиска пароля
введите 3 для закрытия программы
''')
    if mod == '1':
       password = ''
       password_len = random.randint(8, 16)
       for i in range(password_len):
           variant = random.randint(1,3)
           if variant == 1:
               number = random.randint(0, 9)
               password = password + str(number)
           else:
               letter = letters[random.randint(0, len(letters)-1)]
               letters_variant =random.randint(1, 2)
               if letters_variant== 1:
                   letter = letter.upper()
               password = password + letter
       print('ваш пароль:', password)
       saver =input('''для сохранения пароля введите 1
введите любое другое число для отмены сохранения
''')
       if saver == '1':
           password_id = input('''введите имя для пароля
''')
           file.write(password_id)
           file.write(password)
    if mod == '2':
        print()
        file.read()
        print()
    if mod == '3':
        print('программа завершена')
        file.close()
        break

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-06-17
@anton206060

I'm sorry, but in which particular line do you output the contents of the file to the console? You don't have these

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question