urlList = ["https://google.com","https://google.com/help","https://facebook.com","https://facebook.com/help","https://facebook.com/test"]
filterKeys = ["help","test"]
clearUrl = []
for i in urlList:
if filterKeys not in i: #TypeError: 'in <string>' requires string as left operand, not list
clearUrl.append(i)
预期输出['https://google.com','https://facebook.com']
多谢各位
出现此错误是因为您以错误的方式使用了
in
运算符:in
的工作原理如下:代码中的问题在于您使用了:
请尝试:
相关问题 更多 >
编程相关推荐