python array (array) to list (list)

List to array conda 

>>> import numpy as np
>>> a = [1,2,3,4]
>>> b=np.array(a)
>>> b
array([1, 2, 3, 4])
>>>

Successfully converted list a to array b

array to list

array to list

>>> import numpy as np
>>> a = [1,2,3,4]
>>> b=np.array(a)
>>> b
array([1, 2, 3, 4])
# 方法一   数组转list c
>>> c=b.tolist()
>>> c
[1, 2, 3, 4]
# 方法二  数组转list cc
>>> cc = list(b)
>>> cc
[1, 2, 3, 4]
>>>

Guess you like

Origin blog.csdn.net/Vertira/article/details/130207053