列表:list()生成一个list

把字典转换为列表,只转换key的值

>> list({1:2,3:4})
[1, 3]

把元组转换为列表

>> list((1,2,3))
[1, 2, 3]

字符串转换为列表

>> list("1234")
['1', '2', '3', '4']

集合转换为列表

>> set1 = {1,2,3,"a",(1,2)}
>> list(set1)
['a', 1, 2, 3, (1, 2)]

猜你喜欢

转载自blog.51cto.com/13496943/2128090