【发布时间】:2021-07-27 18:15:22
【问题描述】:
我制作了一个随机密钥生成器,它甚至可以用来为你创建一个新密码。
import random
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"
while 1:
key_len = int(input("What length would you like your key to be?: "))
key_count = int(input("How many keys would you like?: "))
for x in range(0,key_count):
key = ""
for x in range(0,key_len):
key_char = random.choice(chars)
key = key + key_char
print("Here's your key: ",key)
输出:
What length would you like your key to be?: 4
How many keys would you like?: 1
Here's your key: 1337
What length would you like your key to be?:
【问题讨论】:
-
你应该包含你得到的错误:SyntaxError: invalid syntax
for x in range(0,key_len)。 -
我忘了。
标签: python python-3.x random generator