leetcode(2):判断list是否为空

Python中判断list是否为空有以下两种方式:

方式一:

1 list_temp = []
2 if len(list_temp):
3     # 存在值即为真
4 else:
5     # list_temp是空的

方式二:

1 list_temp = []
2 if list_temp:
3     # 存在值即为真
4 else:
5     # list_temp是空的
posted @ 2021-06-17 11:26  Tester-**  阅读(74)  评论(0编辑  收藏  举报