我有一个内容如下所示的文件:
label:SMVRMIGBNTRH_NVGRGNR_MFE_GRG_MO_EKR_WE@0
label: ABCDE_FG_0_0@0,ABCDE_FG_1_1_0@8,_EF_0_0@9,ADDRTGG_0_@11,_PGT_KOCPGF_0__@25
label: FKRIG_DW_FERYRH_GMRE_WW_HT_HE@0
label: ABCDE_FG1_2_0@0,ABCDE_FG_1_2_0@8,_EF_2_0@9,ADDRTGG_2_@9,ADDE_HEM_2_0@13,KOCPGFEL_2_0@14
label: ABCDE_FG_3_0@12,ABCDE_FG_1_3_0@8,_EFTG_3_0@9,ADDRT_3_0@11,CPGF_0__@25
如何在@之后获取标签2,3,4并在列表中打印?
Desired Output :
[0,8,11,25]
[0,8,9,9,13,14]
[12,8,9,11,25]
以下是我一直在进行的编码,并没有获得所需的输出
f=open('file.txt','r')
for line in f:
line=line.rstrip()
label=re.findall(r'label:(.*\d),(.*\d)',line)
for item in label :
bits=re.findall(r'label:.*?@(\d+)',line)
if len(bits)>0:
print bits
Output:
['0']
['0']
['12']