新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
判斷python列表不為空的方法
小編給大家分享一下判斷python列表不為空的方法,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
創(chuàng)新互聯(lián)主要企業(yè)基礎(chǔ)官網(wǎng)建設(shè),電商平臺(tái)建設(shè),移動(dòng)手機(jī)平臺(tái),微信小程序等一系列專為中小企業(yè)定制網(wǎng)站產(chǎn)品體系;應(yīng)對(duì)中小企業(yè)在互聯(lián)網(wǎng)運(yùn)營(yíng)的各種問題,為中小企業(yè)在互聯(lián)網(wǎng)的運(yùn)營(yíng)中保駕護(hù)航。
python中判斷一個(gè)列表是否為空,可以使用以下方法
1、is not None 判斷
列表不為空
list_1 = [] if list_1 is not None: print('list is not none')
列表為空
list_1 = [] if list_1[0] is None: print('list_1 is none')
2.if 列表判斷
列表不為空(空列表等于 False)
list_2 = [] if list_2: print('list_2 is not none')
3.length列表長(zhǎng)度判斷
列表為空
list_3 = [] if len(list_3) == 0: print('list_3 is none')
list_3 = [] if len(list): print('list_3 is not none')
以上是判斷python列表不為空的方法的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
網(wǎng)頁題目:判斷python列表不為空的方法
標(biāo)題來源:http://www.dlmjj.cn/article/jcgseg.html