python切片问题,怎么不要中间的,截取两边

比如,a=[1,2,3]我想要取得[1,3]怎么切片....解决方法应该是a[::2]
2025-06-25 04:36:19
推荐回答(1个)
回答1:

b = a[:1] + a[:-1]