如何使此代码有效?
我想检查列表中是否存在某些子字符串,而某些字符串则不是。
if 'A_' and 'V' and '3' and not 'ES' and not 'SF' in my_list[0:3]:
print("It's True")
答案 0 :(得分:2)
您可以使用all()
功能:
if all(x in L for x in wanted) and all(x not in L for x in not_wanted):
# do stuff