python的縮進(jìn)方法
·使用tab鍵
·縮進(jìn)幾個(gè)空格(一般為4個(gè))
比如下面這個(gè)例子:
>>>ifTrue:
...print("thisistrue")//
...print("thisistrue")//
...else:
...print("thisisfalse")//
...print("thisisfalse")//
輸出結(jié)果:
thisistrue
thisistrue
需要注意的是,雖然Python語法允許代碼塊隨意縮進(jìn)幾個(gè)空格,但是位于同一個(gè)代碼塊中的所有語句必須保持相同的縮進(jìn),不能一下縮進(jìn)3個(gè)空格,一下縮進(jìn)4個(gè)空格。
以上內(nèi)容為大家介紹了python培訓(xùn)之縮進(jìn)幾格,希望對(duì)大家有所幫助,如果想要了解更多Python相關(guān)知識(shí),請(qǐng)關(guān)注IT培訓(xùn)機(jī)構(gòu):千鋒教育。