python,提取数据,提取奇数位或者偶数位数据的方法

如有数组num=["1","2","3","4","5"]

怎么按照奇、偶数位取数?

写法如下

num=["1","2","3","4","5"]
print(num[::2])
print(num[1::2])

执行后

 

 具体参考

https://www.cnblogs.com/tianleblog/p/11590123.html

posted @ 2020-12-20 20:26  小贝书屋  阅读(7559)  评论(0编辑  收藏  举报