How to replace single quotes from a list in python

前端 未结 3 779
我寻月下人不归
我寻月下人不归 2021-01-25 10:28

I have a list:

my_list = [\'\"3\"\', \'\"45\"\',\'\"12\"\',\'\"6\"\']

This list has single and double quotes and the item value. How can I repl

3条回答
  •  萌比男神i
    2021-01-25 10:38

    You can use split:

    [x.split('"')[1] for x in my_list]
    

    or you can use:

    [x.strip('"') for x in my_list]
    

提交回复
热议问题