# 字母:string.ascii_letters
# 大写:string.ascii_uppercase
# 小写:string.ascii_lowercase
import string import random n_int = int(input("请输入随机字母个数:")) # 生成指定数量的字符,list格式 random_letter = random.sample(string.ascii_letters,n_int) # list转成string
str = ''.join(random_letter)print(str)
标签:string,小写字母,random,大写字母,int,随机,ascii From: https://www.cnblogs.com/zhangmeiyan/p/16802064.html