📜  如果不在列表中,则从列表中删除 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:59.126000             🧑  作者: Mango

代码示例1
>>sents = ['@$\tthis sentences needs to be removed', 'this doesnt',
     '@$\tthis sentences also needs to be removed',
     '@$\tthis sentences must be removed', 'this shouldnt',
     '# this needs to be removed', 'this isnt',
     '# this must', 'this musnt']
>>>[x for x in sents if not x.startswith('@$\t') and not x.startswith('#')]
['this doesnt', 'this shouldnt', 'this isnt', 'this musnt']