当前位置:主页 > 软件编程 > Python代码 >

python: 判断tuple、list、dict是否为空的方法

时间:2021-05-02 08:18:43 | 栏目:Python代码 | 点击:

Test

tuple_test = ()
assert not tuple_test

list_test = []
assert not list_test

dict_test = {}
assert not dict_test

Summary

根据实验结果可知,直接通过:

if not xxx:

即可判断 tuple、list、dict 是否 为空 。

您可能感兴趣的文章:

相关文章