Removing Punctuation From Python List Items

后端 未结 5 712
耶瑟儿~
耶瑟儿~ 2020-11-29 08:56

I have a list like

[\'hello\', \'...\', \'h3.a\', \'ds4,\']

this should turn into

[\'hello\', \'h3a\', \'ds4\']

5条回答
  •  甜味超标
    2020-11-29 09:22

    To make a new list:

    [re.sub(r'[^A-Za-z0-9]+', '', x) for x in list_of_strings]
    

提交回复
热议问题