首页 > 其他分享 >判断语句 之 逻辑运算

判断语句 之 逻辑运算

时间:2023-01-22 11:11:26浏览次数:37  
标签:语句 major 逻辑运算 version 判断 ansible debug distribution

逻辑运算 释义
and 逻辑与
or 逻辑或
not 逻辑取反

示例一:
等同于:

if ansible_distribution == "CentOS" and ansible_distribution_major_version == "7":
    print("我是centos7")
- hosts: all
  tasks:
  - name: debug
    debug:
      msg: "我是centos7"
    when:
    - ansible_distribution == "CentOS"
    - ansible_distribution_major_version == "7"

示例二:

not 取反

- hosts: all
  tasks:
  - name: debug
    debug:
      msg: "我不是centos6"
    when:
    - ansible_distribution == "CentOS"
    - not ansible_distribution_major_version == "6"

标签:语句,major,逻辑运算,version,判断,ansible,debug,distribution
From: https://www.cnblogs.com/wangend/p/17064311.html

相关文章

  • 判断语句示例
    判断添加用户-hosts:allvars:-username:test1tasks:-name:detectwhethertheuserexistsshell:id{{username}}register:result......
  • 一文解决如何使用 C 语言判断质数(素数)[ 附解析与源码 ]
    前言质数历来都是数学界的宠儿,是数学里神秘的谜团。质数又和C语言有着不解之缘,本篇文章将讲解如何用C语言判断质数。为了方便大家在读完此文章后使用文中程序,我会将......
  • 判断回文数
    题目:  解法一:将整数转换为字符串python3:classSolution:defisPalindrome(self,x:int)->bool:returnstr(x)==str(x)[::-1]解法二:只需要判......
  • ifelse嵌套屎山的解决方法-卫语句
    卫语句(Guard)什么是卫语?卫语句是一种编程思想,提前检查边界,保卫代码。一、什么时候使用卫语句大厂开发规范,超过三个ifelse建议使用卫语句、策略模式、状态模式等方式重......
  • 条件控制语句
    if语句包含零个或多个elif子句,及可选的else子句。关键字‘elif‘是‘elseif’的缩写,适用于避免过多的缩进。可以把if…elif…elif…序列看作是其他语言中......
  • 循环控制语句 之 with_together
    功能类似于:列表元素数量上要一一对应foriinzip([1,2,3],['a','b','c']):print(i)-hosts:alltasks:-name:debugdebug:msg:"{{item}}"......
  • 循环控制语句 之 with_indexed_items
    添加索引-hosts:alltasks:-name:debugdebug:msg:"{{item}}"with_indexed_items:-[1,2,3]-['a','b','c','d']-hosts:all......
  • 循环控制语句 之 with_together
    功能类似于:foriinzip([1,2,3],['a','b','c']):print(i)-hosts:alltasks:-name:debugdebug:msg:"{{item}}"with_together:......
  • 循环控制语句 之 with_nested
    嵌套循环可以理解为:foriin[1,2,3]:forjin['a','b','c','d']:print(i,j)-hosts:alltasks:-name:debugdebug:msg:"{{item......
  • 循环控制语句 之 with_list
    with_list不展开循环嵌套的列表。功能类似于foriinzip([1,2,3],['a','b','c']):print(i)-hosts:alltasks:-name:debugdebug:msg:"{{......