我是靠谱客的博主 仁爱书本,这篇文章主要介绍python list()函数 (从可迭代对象返回初始化的新列表),现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
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, ...

示例:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
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内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部