1 import random 2 3 firstname = ‘赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许‘ 4 second = ‘中万斯近元伟丽利国士文连百宏可立成海友南广云基‘ 5 third = ‘隆智渝顺乐天杰夫煜兵思霆炜祺亮剀炫翔维瑞韬嘉林庆玮勤栋源路焕霖彩明邦闻朵皓瀚荣奕涓艺‘ 6 7 namelist = [] 8 many = input(‘请输入需要生成姓名的数量:\n‘)‘) 9 for i in range(int(many)): 10 data = [2,3] 11 namelen = random.choice(data) 12 if namelen == 2: 13 newname = random.chocie(firstname) + random.choice(second) 14 else: 15 newname = random.choice(firstname) + random.chocie(second) + random.choice(third) 16 namelist.append(newname) 17 print("生成的虚拟姓名列表为:\n" + "\n".join(namelist))
原文地址:https://www.cnblogs.com/reaix/p/12344096.html
时间: 2024-10-20 10:01:48