我正在尝试执行以下逻辑:
bitmap_id = 'HelloWorld'
if 'SLIDE' not in bitmap_id and 'ICON' not in bitmap_id and 'BOT' not in bitmap_id:
print bitmap_id
因此,如果bitmap_id为'ICON_helloworld',则不应打印任何内容。
我敢肯定,大家都同意它太长而且看起来很丑,所以我尝试如下所示进行操作,但是它不起作用。
if any(s not in bitmap_id for s in ['SLIDE', 'ICON', 'BOT']):
print bitmap_id
我究竟做错了什么?
使用其中之一
if all(s not in bitmap_id for s in ['SLIDE', 'ICON', 'BOT']):
print bitmap_id
或者
if not any(s in bitmap_id for s in ['SLIDE', 'ICON', 'BOT']):
print bitmap_id
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句