Convert strings of list to list of integers inside a list

前端 未结 5 1624
长发绾君心
长发绾君心 2021-01-28 20:02

I have a list of strings and those strings are lists. Like this: [\'[1,2,3]\',\'[10,12,5]\'], for example. I want to get a list of lists or even every list there: <

5条回答
  •  面向向阳花
    2021-01-28 20:31

    Use regular expressions:

    new_list = [[int(j) for j in re.findall(r'\d+', i)] for i in old_list]
    

提交回复
热议问题