author = 'pengwei' #py的判断语句 a, b, c = 1, 2, 3 if a > b: print(1) else: print(0) #python中是没有swith语句的 if a > b: print(1) elif a > c: print(2) else: print(3) c = a if a > b else b c = [b, a][a > b] c = (a > b and [a] or [b])[0] #py循环语句 while a + b > 3: c = a + b for item in [1, 2, 3, 4, 5]: print(item) for str in 'abcdef': print(str) for i in range(5): print(i)
注意:
python中没有switch语句,也没有do while