简体   繁体   English

[1,2,3]和array([1,2,3])有什么区别

[英]What is the difference between [1,2,3] and array([1,2,3])

I am learning python and I find a=[1,2,3] is almost the same as a=array([1,2,3]),though the latter will show [1 2 3] when I print it. 我正在学习python,我发现a = [1,2,3]与a = array([1,2,3])几乎相同,尽管在我打印时后者会显示[1 2 3]。 What is the difference between them? 它们之间有什么区别?

The first is a Python list and the second is, presumably a numpy array. 第一个是Python列表,第二个大概是一个numpy数组。 numpy arrays have drastically different features than lists: lists are easily expanded and contracted 1d vectors of arbitrary Python objects. numpy数组的功能与列表完全不同:列表易于扩展和收缩任意Python对象的1d向量。 numpy arrays are memory-compact representations of mostly numbers of arbitrary dimension and fixed size, mainly for use with numerical programming. numpy数组是紧凑的表示形式,主要表示任意维数和固定大小的数字,主要用于数值编程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 deque( [1,2,3] ) 和 deque.append( [1,2,3] ) 有什么区别? - What is the difference between deque( [1,2,3] ) and deque.append( [1,2,3] )? Python:(1,2,3) 和 [1,2,3] 有什么区别,我应该在什么时候使用它们? - Python: what is the difference between (1,2,3) and [1,2,3], and when should I use each? Python sqlite => reportlab数据[1,2,3]和[[1],[2],[3]]之间有什么区别 - Python sqlite => reportlab data what is difference between [1,2,3] and [[1],[2],[3]] 如何将列表 [1,2,3] 更改为 1 2 3 之间有空格? - How to change a list [1,2,3] into 1 2 3 with spaces in between? “ TypeError:(1,2,3)不可序列化为JSON”是什么意思? - What does “TypeError : (1,2,3) is not JSON serializable” mean? 为什么在IPython中将b = 1,2,3解析为(',b','=','1,2,3')? - Why is ,,b = 1,2,3 parsed as (',b', '=', '1,2,3') in IPython? 在 keras 后端的 K.sum 中,axis=[1,2,3] 是什么意思? - What does axis=[1,2,3] mean in K.sum in keras backend? python将列表[0,1,2,3,4,5]转换为[0,1,2],[1,2,3],[2,3,4] - python convert list [0, 1, 2, 3, 4, 5] to [0, 1, 2], [1,2,3], [2,3,4] 如何将 [1,2,3] 转换为 [[1],[2],[3]]? - how do I convert [1,2,3] to [[1],[2],[3]]? 如何将“[nan,1,2,3]”字符串转换为列表[nan,1,2,3]? - How can I convert "[nan,1,2,3]" string to list [nan,1,2,3]?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM