python 生成随机的用户名和密码
分类:Python
import random import string # 生成随机用户名 def generate_username(length=16): letters = string.ascii_lowercase return ''.join(random.choice(letters) for i in range(length)) # 生成随机密码 def generate_password(length=16): characters = string.ascii_letters + string.digits + string.punctuation return ''.join(random.choice(characters) for i in range(length)) username = generate_username() password = generate_password() print("新用户的用户名是:", username) print("新用户的密码是:", password)