Python 如何检查某些字符串是否为;在;还有一些",;不在「;名单?
如何使此代码工作 我想检查一些子字符串是否在列表中,而一些不在列表中Python 如何检查某些字符串是否为;在;还有一些",;不在「;名单?,python,string,list,python-3.x,contains,Python,String,List,Python 3.x,Contains,如何使此代码工作 我想检查一些子字符串是否在列表中,而一些不在列表中 if 'A_' and 'V' and '3' and not 'ES' and not 'SF' in my_list[0:3]: print("It's True") 您可以使用以下功能: if all(x in L for x in wanted) and all(x not in L for x in not_wanted): # do stuff 你能在我的示例中演示如何使用这个函数吗?@Luk:只
if 'A_' and 'V' and '3' and not 'ES' and not 'SF' in my_list[0:3]:
print("It's True")
您可以使用以下功能:
if all(x in L for x in wanted) and all(x not in L for x in not_wanted):
# do stuff
你能在我的示例中演示如何使用这个函数吗?@Luk:只需使用
L=my_list[:3];通缉令=[“A_u”,“V”,“3”];非通缉令=[“ES”,“SF”]