关于如何在Python中重复数组中某个值的任何建议?例如,我想只重复2次array_a:
array_a = [1, 2, 1, 2, 1, 1, 2]
Run Code Online (Sandbox Code Playgroud)
想要的结果是:我重复每一个2并离开1:
array_a = [1, 2, 2, 1, 2, 2, 1, 1, 2, 2] # only the `2` should be repeated
Run Code Online (Sandbox Code Playgroud)
我试过numpy,我可以复制整个数组,但不是一定的值.