-1
numpy中的任何函數都可以實現這個功能嗎?以下功能f
是一種尷尬從python的另一個列表中創建多個副本列表
def f(l,times):
res=[]
for i in range(len(l)):
res+=[l[i]]*times[i]
return res
In [93]:f([1,2,3],[2,2,2])
Out [93]:[1, 1, 2, 2, 3, 3]