Python if not in multiple condition judgment code _python

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.