Python if not in Multi-condition judgment code, pythonif
Baidu homework help:
Python if not in Multi-condition judgment
S = ['1', '2'] Judgment Condition
Sta = "12345"
Normally,
If "1" not in sta and "2" not in sta:
Print sta
If we know that the conditions are okay, if there are many conditions, this method will certainly not work?
How can we use a formula to satisfy the above judgment?
Below is a pseudo code to familiarize you with it...
The requirement is that keywords such as "recruitment", "recruitment", and "social recruitment" are not allowed in the content. Only qualified keywords are printed ..
#! /Usr/bin/env python #-*-coding: gbk-*-#-*-coding: utf_8-*-# Date: # Created by dedicated wait # blog http://www.waitalone.cn/filters = ['recruitment ', 'hiring', 'social recruitment '] contents = ['dedicated waiting for security team hiring, http://www.bkjia.com /', 'Wait for security team recruitment, http://www.bkjia.com/', 'Wait for security team recruitment, http://www.bkjia.com/', 'Wait for information security blog, http://www.bkjia.com/', wait for content in contents: if any (keyword in content for keyword in filters): continue print content
Follow-up:
What does if all mean?
Answer:
All function test whether all conditions in the iteration object are true
All ([True, False, True]) returns False
Is there at least one condition for any testing?
Any ([True, False, False]) returns True