當前位置:成語大全網 - 書法字典 - Python List to Numpy Array:List,]只有壹維,如何表示元素3?

Python List to Numpy Array:List,]只有壹維,如何表示元素3?

如果想把array(,])展平成array(),有三種方法:flat屬性,flat方法,ravel方法。

比如:

& gt& gt& gt將numpy作為np導入

& gt& gt& gta = np.array(,])

& gt& gt& gta

數組(,

])

& gt& gt& gtb = np.array(a .扁平)

& gt& gt& gtb

數組()

& gt& gt& gtc = a.flatten()

& gt& gt& gtc

數組()

& gt& gt& gtd = a .拉威爾()

& gt& gt& gtd

數組()