python filter 过滤点2个条件,是要怎么写呢?
问题描述:
def skuname_filter(skuname):
return "Nonprofit Staff Pricing" ,"DaaS Bundle" not in skuname
ret = list(filter(skuname_filter, skuname))
print(ret)
执行结果:
['DaaS Bundle -', 'xxxxx Nonprofit Staff Pricing', 'MS']
20210812
<lianchun_automation.API.DB_CustomerInformation.DBCheck object at 0x114bb1400>
['DaaS Bundle -', 'xxxxx Nonprofit Staff Pricing', 'MS']
我怎么写可以,可直接将 "Nonprofit Staff Pricing"和"DaaS Bundle"过滤掉只将“ MS”输出就行呢?
答
def skuname_filter(skuname):
return "Nonprofit Staff Pricing" not in skuname and "DaaS Bundle" not in skuname 用逻辑与
答
条件 skuname = ["DaaS Bundle -", "xxxxx Nonprofit Staff Pricing", "MS"]
答
没有过滤规则? 要取MS 不直接可以skuname[-1] 么?