“Python генерирует случайный пароль” Ответ

Генератор пароля Python

import string
from random import *
characters = string.ascii_letters + string.punctuation  + string.digits
password =  "".join(choice(characters) for x in range(randint(8, 16)))
print password
Glorious Giraffe

генерировать случайную строку Python

import string
import random

length=5
#python2
randomstr = ''.join(random.sample(string.ascii_letters+string.digits,length))


#python3
randomstr = ''.join(random.choices(string.ascii_letters+string.digits,k=length))

                                  
Worrisome Wallaby

Python Password Generator

import random

lower = "abcdefghijklmnopqrstuvwxyz"
upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
numbers = "0123456789"
symbols = "@#$&_-()=%*:/!?+."


string = lower + upper + numbers + symbols
length = int(input("How Many Characters Do You Want Your Password To Be: "))
password = "".join(random.sample(string, length))

print("Here Is Your Password:", password)
Sleepy Skimmer

Python Получите случайный символ из строки

import random

#String
string = "abcdefghijklmnopqrstuvwxyz"
array = []
for c in string:
  array += [c]
 
print(array[random.randint(0, len(array)-1)])

# Faster and more efficient
random.choice(string)
Xanthous Xenomorph

Python генерирует случайный пароль

from random import choice
from string import printable # variable in the module that contains all the possible chars

# This is optional__________________
class LengthError(Exception):
    pass


def length_checker(length):
    if length < 6 or length > 40:
        raise LengthError("Password length must be between 6 and 40 characterse.")
#_______________________________________

# removing unwanted characters
chars = list(printable)
chars.pop(85)
for i in range(5):
    chars.pop()


while True: #loop (optioanl)
    try:
        print("Enter your password length:")
        max_length = int(input())
        if max_length == 0:
            exit()
        length_checker(max_length) # optional
        password = ""
        for i in range(max_length):
            password += choice(ascii_characters)
        print(f"Your generated password:{password}")
    except LengthError as e: # optional
        print(e)
    except ValueError:
        print("We can't process this with letters, symplos, emptyspaces or any other non-integer type. Please enter a valid range.")
Attractive Albatross

Python генерирует случайный пароль

from random import choice
from string import printable # variable in the module that contains all the possible chars

# This is optional__________________
class LengthError(Exception):
    pass


def length_checker(length):
    if length < 6 or length > 40:
        raise LengthError("Password length must be between 6 and 40 characterse.")
#_______________________________________

# removing unwanted characters
chars = list(printable)
chars.pop(85)
for i in range(5):
    ascii_characters.pop()


while True: #loop (optioanl)
    try:
        print("Enter your password length:")
        max_length = int(input())
        if max_length == 0:
            exit()
        length_checker(max_length) # optional
        password = ""
        for i in range(max_length):
            password += choice(ascii_characters)
        print(f"Your generated password:{password}")
    except LengthError as e: # optional
        print(e)
    except ValueError:
        print("We can't process this with letters, symplos, emptyspaces or any other non-integer type. Please enter a valid range.")
Attractive Albatross

Ответы похожие на “Python генерирует случайный пароль”

Вопросы похожие на “Python генерирует случайный пароль”

Больше похожих ответов на “Python генерирует случайный пароль” по Python

Смотреть популярные ответы по языку

Смотреть другие языки программирования