本文實(shí)例講述了python中pass語句用法。分享給大家供大家參考。具體分析如下:
1、空語句 do nothing
2、保證格式完整
3、保證語義完整
4、以if語句為例:
C/C++中寫法:
if(true); // do nothingelse{} // do nothing
python中寫法:
if true:pass # do nothingelse:print "do something."
測試程序:定義一個(gè)空函數(shù)
>>> def nullfunc():... pass...>>> nullfunc()>>>
希望本文所述對大家的Python程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選