曾經我以為python是像pascal那樣begin開始end結束,
直到今天……
我才知道python是用縮進作為代碼段標識的……
1 >>> def test(n): 2 ... if n==1: 3 ... print("one") 4 ... print("two") 5 ... elif n==2: 6 ... print("three") 7 ... else: 8 ... print("four") 9 ... 10 >>> n=1 11 >>> test(1) 12 one 13 two 14 >>> n=2 15 >>> test(2) 16 three 17 >>> n=5 18 >>> test(5) 19 four