import randomoffices =[[],[],[]] names = ["a","b","c","d","e","f","g","d"] for name in names: a = random.randint(0,2) offices[a].append(name) i = 1 for office in offices: print("分配个数为%d"%(len(office)),"-"*20) i += 1 for name in office: print("对象名字:%s"%name) print("\n") print("-"*20)
python八个对象随机分配到三个库,应用random库