导语:
本文主要介绍了关于python判断列表值是否为空的相关知识,包括python 判断空值,以及pandas判断空值这些编程知识,希望对大家有参考作用。
python中判断一个列表是否为空,可以使用以下方法
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列表长度判断
列表为空
list_3 = []
if len(list_3) == 0:
print('list_3 is none')
list_3 = []
if len(list):
print('list_3 is not none')
本文为原创文章,版权归知行编程网所有,欢迎分享本文,转载请保留出处!
你可能也喜欢
- ♥ 如何查看python是否安装09/07
- ♥ 如何组织python代码12/23
- ♥ python中如何判断elif结构语句?12/04
- ♥ 火了!16岁高中生做的 Python 3.9 八大新特性图01/16
- ♥ python函数的返回值是多少08/16
- ♥ python如何控制打印多少小数位?08/28
内容反馈