import random
import string
def generate_password(length):
characters = string.ascii_letters + string.digits + string.punctuation # Все символы
password = ''.join(random.choice(characters) for i in range(length))
return password
num_passwords = int(input("Введите количество паролей для генерации: "))
generated_passwords = set()
while len(generated_passwords) < num_passwords:
length = random.randint(8, 16)
password = generate_password(length)
generated_passwords.add(password)
with open('file.txt', 'w') as file:
for password in generated_passwords:
file.write(password + '\n')
print(f'Сгенерированные пароли записаны в file.txt')