上代码:
import random
def generate_password():# 生成包含大小写字母的字符串letters = ''.join(random.choice('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') for _ in range(8))# 生成6位数字字符串digits = ''.join(str(random.randint(0, 9)) for _ in range(9))# 拼接字母和数字password = letters + digits# 打乱密码字符串,确保随机性return passwordif __name__ == '__main__':print(generate_password())