SHELL学习笔记----IF条件判断,判断条件 前言: 无论什么编程语言都离不开条件判断.SHELL也不例外. if list then do something here elif list then do another thing here else do something else here fi EX1: #!/bin/bash if [ `uname -m` == "x86_64" ]…
条件语句 if # if if condition then command fi # if else if condition then command else command fi # if elif if condition then command elif condition then command else command fi 需要注意的是 elif下面还有个then for # 第一种表达方式 for v in item1 item2 item3 itemN do comma…
5.1 if语句 没什么好说,if语句语法如下: if expression: expr_true_suit 5.1.1多重条件表达式 单个if语句可以通过布尔操作符and,or,not实现多重条件判断或否定判断. if not warn and (system_load>=10): print 'WARNING:LOSING RESOURCE' warn+=1 5.2 else 语句 如果if条件为假程序将执行else后的语句. if expression: expr_true_suit el…
1. if elif else 2. 条件表达式:三元操作符: smaller = x if x < y else y == if x < y : smaller =x else : smaller = y 3. range(start, end, step=1) 4. xrange(): 当有一个很大范围的列表时, xrange()更为合适,因为它不会再内存里创建列表的完整拷贝,他只被用在for循环中,性能比range()要好, 因为它不生 成整个列表. 5. sorted(), re…