这是我的列表:N= 9
Mylist=[9,8,7,6,5,4,3,2,1]
对于此输入输出应为:
9 8 7
6 5 4
3 2 1
听起来您想知道如何将列表转换为特定形状的numpy数组。文档在这里。
import numpy as np
my_list=[3,9,8,7,6,5,4,3,2,1]
# Dropping the first item of your list as it isn't used in your output
array = np.array(my_list[1:]).reshape((3,3))
print(array)
输出
[[9 8 7]
[6 5 4]
[3 2 1]]