概述
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 list()函数 (从可迭代对象返回初始化的新列表)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复