Python在列表中生成多个范围值

Python在列表中生成多个范围值,python,pandas,Python,Pandas,我想在列表中生成多个范围值。我的代码如下 drop_cols = [6,21,range(38:14*16:16),range(229:229+14*16:16)] 我目前的产出是: drop_cols = [6,21,range(38:14*16:16),range(229:229+14*16:16)] ^ SyntaxError: invalid syntax 我的预期产出是: drop_cols = [6,21,38,....

我想在列表中生成多个范围值。我的代码如下

drop_cols = [6,21,range(38:14*16:16),range(229:229+14*16:16)]
我目前的产出是:

drop_cols = [6,21,range(38:14*16:16),range(229:229+14*16:16)]
                              ^
SyntaxError: invalid syntax
我的预期产出是:

drop_cols = [6,21,38,....,229,..]

使用
np.r

drop_cols = np.r_[2:5, 10:15, 19]
drop_cols
输出:

array([ 2,  3,  4, 10, 11, 12, 13, 14, 19])

range
使用逗号分隔字段。。。看起来你可能在寻找
[6,21,*range(38,14*16,16),*range(229,220+14*16,16)]
?或者使用
np.r\
np.r\6,21,38:14*16:229+14*16:16]
@JonClements它奏效了。我实际上忘记了
范围
使用逗号。谢谢。但是我的要求是不同的范围和不同的起始点。