human3在数组1 2 3 4 5中相邻两个数字中间插入1个0。切片赋值 使用Python
arr = [1, 2, 3, 4, 5] for i in range(len(arr)-1): arr[i:i+1] = [arr[i], 0] print(arr)
原文地址: http://www.cveoy.top/t/topic/fd0n 著作权归作者所有。请勿转载和采集!
安全问答是一个知识全球问答,包含丰富的问答知识
arr = [1, 2, 3, 4, 5] for i in range(len(arr)-1): arr[i:i+1] = [arr[i], 0] print(arr)
原文地址: http://www.cveoy.top/t/topic/fd0n 著作权归作者所有。请勿转载和采集!