Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何检查某些字符串是否为;在;还有一些",;不在「;名单?_Python_String_List_Python 3.x_Contains - Fatal编程技术网

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”]