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…
内容概要 for循环 range(start,end,step)函数 生成随机数列表 list()函数 将range()的结果整合到某个列表 列表的操作 切片(start: end :step) 元组 for循环 用for循环可以遍历列表中的每一个元素 demo1: people = ['alice' , 'bob' , 'david'] for person in people: print(person) # 缩进和冒号很重要,是python语法中的一部分 > alice bob david…
>>> movies=["The Holy Grail", 1975, "The Life of Brian", 1979, "The Meaning of Life", 1983] >>> for eachMovie in movies: print(eachMovie) 按下两个回车后输出结果如下: The Holy Grail 1975 The Life of Brian 1979 The Meaning…