可以使用list()函数将集合转化为列表。
示例代码如下:
my_set = {1, 2, 3, 4, 5}
my_list = list(my_set)
print(my_list) # 输出:[1, 2, 3, 4, 5]
在上面的代码中,使用list()函数将集合my_set转化为列表my_list。最后打印输出my_list,结果为[1, 2, 3, 4, 5]。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:python集合如何转化为列表