使用标准在Python中列出生成器

时间:2015-11-17 11:09:06

标签: python string python-3.x

如何将所有标准设置为一个列表并在字符串中搜索?

name = [s for s in files if (("реес")   in s.lower() or ("m&s")   in s.lower()  )and 
                ("элект") not  in s.lower() and
                ("сво") not  in s.lower() and
                ("кхп") not  in s.lower() and 
                ("rar") not  in s.lower() and
                ("пор") not  in s.lower() and 
                ("инф") not  in s.lower() and 
                ("бум") not  in s.lower() and
                ("доп") not  in s.lower() and 
                ("msg") not  in s.lower() and 
                ("сро") not  in s.lower() and 
                ("ank") not  in s.lower()]

1 个答案:

答案 0 :(得分:3)

您可以使用嵌套条件。

[s for s in files if all(val not in s.lower() for val in ('abc', 'def', 'ghi'))]