1、only size-1 arrays can be converted to Python scalars
問題來源:需要把一個float數組A轉為int,於是直接在代碼中寫了 B=int(A),從而報錯。
原因:int函數只能對單個數字進行,而不能對一個數組進行
解決方法:用map函數,對數組中的每個元素整數化
B=list( map( int , A ) )
2、list indices must be integers or slices, not tuple
(7條消息) TypeError: list indices must be integers or slices, not tuple_yp736628082的博客-CSDN博客