Python 基本语法
1 #coding=utf-8 2 a=1 3 b=2 4 c=3 5 #if else 6 if a==1: 7 print("a=1") 8 else: 9 print("a!=1") 10 11 #if elif 12 if b==3: 13 print("b=3") 14 elif c==4: 15 print("c=4") 16 else: 17 print("c!=4") 18 # 三目运算符 19 print("表达式1" if c==3 else "表达式2") 20 21 #循环语句 22 index=0 23 while index<5: 24 index+=1 25 print("while {0}".format(index)) 26 else: 27 print("While Over") 28 index=0 29 for num in range(0,5): 30 print("for {0}".format(num)) 31 else: 32 print("For Over") 33 34 for num in range(5): 35 if num==3: 36 print("num==3 break") 37 break # or continue