python list()函数 (从可迭代对象返回初始化的新列表)
生活随笔
收集整理的這篇文章主要介紹了
python list()函数 (从可迭代对象返回初始化的新列表)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Init signature: list(self, /, *args, **kwargs)
Docstring:
list() -> new empty list
list(iterable) -> new list initialized from iterable's items 從可迭代對象返回初始化的新列表
Type: type
Subclasses: _HashedSeq, StackSummary, SList, List, List, List, List, _ImmutableLineList, FormattedText, NodeList, ...
示例:
a = np.array([[1, 2], [3, 4]]) b=[1,2,3,4] c=[[1],[2],[3],[4]] d=np.array([[1],[2],[3],[4]]) e="hello" f=['h','e','l','l','o'] print(list(a)) # [array([1, 2]), array([3, 4])] print(list(b)) # [1, 2, 3, 4] print(list(c)) # [[1], [2], [3], [4]] print(list(d)) # [array([1]), array([2]), array([3]), array([4])] print(list(e)) # ['h', 'e', 'l', 'l', 'o'] print(list(f)) # ['h', 'e', 'l', 'l', 'o']總結
以上是生活随笔為你收集整理的python list()函数 (从可迭代对象返回初始化的新列表)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python numpy数组转换成列表方
- 下一篇: python 板蓝根字典变量的创建