Baidu Homework Help Questions:
Python if not in multiple conditions judge how to write
s = [' 1 ', ' 2 '] judge the condition
STA = "12345"
It's the normal thing,
If ' 1 ' not in STA and ' 2 ' not in STA:
Print STA
If you know the conditions are OK, if you judge the conditions of a lot of this method is certainly not?
How to use a formula to satisfy the above judgment?
Below write a pseudo code, to everybody familiar with can ...
Demand for, the content must not appear ' recruitment ', ' Invite ', ' social recruit ' and other keywords, meet the conditions before printing out.
#!/usr/bin/env python
#-*-CODING:GBK-*-#-*-coding:utf_8-*-# DATE:2016/5/13 # Created by
alone wait
# Blog http://www.waitalone.cn/
filters = [' Recruitment ', ' hire ', ' social Recruit ']
contents = [
' Wait for the security team to hire, http://www.jb51.net/ ', ' Waiting alone for
security team recruitment, http://www.jb51.net/',
' alone waiting for security team recruit, http://www.jb51.net/',
' alone Waiting For information security blog, http:// www.jb51.net/',
] for
content in contents:
If all (keyword in content for keyword in filters): CONTINUE
print Content
Ask:
If all what do you mean?
Chase Answer:
The all function tests whether all conditions in the iteration object are valid
All ([true,false,true]) results are False
Any test if at least one condition is set up
Any ([true,false,false]) result is True