1. 判斷語句
if True:
print("hi,")
print("true")
else:
print("false")
這裏會打印:
hi,
true
注意: Python的布爾值常量,首字母是大寫的。
2. 多行輸出用“\”號來隔開
item_one = 1 item_two = 2 item_three = 3 total = item_one + \ item_two + \ item_three print(total)
語句中包含 [], {} 或 () 括號就不需要使用多行連接符。如下實例:
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']