[‘* sss *’或”]返回[‘* sss *’],因为”为False且* sss *被视为True.
这意味着您的列表显示为[True或False].选择真因子(在这种情况下,* sss *.
你可能想做的事情如下:
if d['pw'] in ['*sss*', '']:
甚至:
if d['pw'] == '*sss*' or d['pw'] == '':
作为一个班轮(有点):
>>> for res in ("pw verified and it is '*sss*' or '' " if i['pw'] in ['*sss', ''] else "pw is not any of two'*sss*' or ''" for i in data):
... print res
...
pw is not any of two'*sss*' or ''
pw verified and it is '*sss*' or ''
pw verified and it is '*sss*' or ''
pw is not any of two'*sss*' or ''