import rea = ‘abc[1,2,3]abc’t=re.findall(r'\[(.+?)\]',a)t1=re.findall(r'\d+',t[0])b=[int(i) for i in t1]