python中list函数

list函数将可迭代对象转化为列表

1、

>>> list("abcde")    ## 字符串作为可迭代对象,将字符串转化为列表
['a', 'b', 'c', 'd', 'e']
>>> a = list("abcde")
>>> a
['a', 'b', 'c', 'd', 'e']
>>> type(a)
<class 'list'>
>>> b = ("aaa","bbb","ccc","ddd","eee")
>>> b
('aaa', 'bbb', 'ccc', 'ddd', 'eee')
>>> c = list(b)       ## 元组作为可迭代对象,将元组转化为列表
>>> c
['aaa', 'bbb', 'ccc', 'ddd', 'eee']
>>> type(c)
<class 'list'>
原文地址:https://www.cnblogs.com/liujiaxin2018/p/14446913.html