Home  >  Article  >  Backend Development  >  The difference between python arrays and lists

The difference between python arrays and lists

(*-*)浩
(*-*)浩Original
2019-08-02 14:34:307534browse

The difference between python arrays and lists:

The difference between python arrays and lists

list does not have all the attributes of array (such as dimensions, transposition, etc.).

Code: (Recommended learning: Python video tutorial)

#eg1_1
import numpy as np
a = np.array([[1,2,0,1],[1,6,9,55],[7,8,9,5]])#a为数组
print(a.T)
 
#Result:
[[ 1  1  7]
 [ 2  6  8]
 [ 0  9  9]
 [ 1 55  5]]
 
#eg1_2
a = [[1,2,0,1],[1,6,9,55],[7,8,9,5]] #a为列表
print(a.T)
 
#Result:
'list' object has no attribute 'T'

For more Python related technical articles, please visit Learn in the Python tutorial column!

The above is the detailed content of The difference between python arrays and lists. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn