当前位置:主页 > 软件编程 > Python代码 >
时间:2021-07-18 08:26:28 | 栏目:Python代码 | 点击:次
如下所示:
a = [0, 1, 2, 3, 4, 0, 2, 3, 6, 7, 5] selected = [x for x in a if x in range(1, 5)] # 找到a中属于[1,5)中的元素 print selected