[x]
是包含 的列表x
。
list(x)
接受x
(必须已经可以 !)并将其转换为列表。
>>> [1] # list literal
[1]
>>> ['abc'] # list containing 'abc'
['abc']
>>> list(1)
# TypeError
>>> list((1,)) # list constructor
[1]
>>> list('abc') # strings are iterables
['a', 'b', 'c'] # turns string into list!
列表构造函数list(...)
-像python的所有内置集合类型(集合,列表,元组,collections.deque等)一样- 可以采用一个可迭代的参数并将其转换。