简体   繁体   中英

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. What is the difference between them?

The first is a Python list and the second is, presumably a numpy array. numpy arrays have drastically different features than lists: lists are easily expanded and contracted 1d vectors of arbitrary Python objects. numpy arrays are memory-compact representations of mostly numbers of arbitrary dimension and fixed size, mainly for use with numerical programming.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM