我有一个txt数据文件,格式如下,总共8000行。请问,如果我的筛选条件是:希望选出M5_1M, M5_2S,M5_3Y,一直到M5_nX的行,我应该怎么写python脚本呢?n=1,2,3,4,5,6,一直到289, X=M,S,Y或者其他满足条件的字母。十分感谢
M5_1M OTC=589 POI=986 RTY=1254
M5_1A OTC=589 POI=986 RTY=1254
M5_1S OTC=589 POI=986 RTY=1254
M5_1T OTC=589 POI=986 RTY=1254
M5_1Y OTC=589 POI=986 RTY=1254
M5_1D OTC=589 POI=986 RTY=1254
M5_1S OTC=589 POI=986 RTY=1254
M5_2M OTC=589 POI=986 RTY=1254
M5_2A OTC=589 POI=986 RTY=1254
M5_2S OTC=589 POI=986 RTY=1254
M5_2T OTC=589 POI=986 RTY=1254
M5_2Y OTC=589 POI=986 RTY=1254
M5_2D OTC=589 POI=986 RTY=1254
M5_S OTC=589 POI=986 RTY=1254
M5_3M OTC=589 POI=986 RTY=1254
M5_3A OTC=589 POI=986 RTY=1254
M5_3S OTC=589 POI=986 RTY=1254
M5_3T OTC=589 POI=986 RTY=1254
M5_3Y OTC=589 POI=986 RTY=1254
M5_3D OTC=589 POI=986 RTY=1254
M5_3S OTC=589 POI=986 RTY=1254