[英]In Python, what is the easiest way to find the smallest value in a list which contains both strings and floats?
[英]What is the easiest way to detect if a list contains only empty arrays?
检查 arrays 列表以查看它们包含的 arrays 是否全部为空的最简单方法是什么?
例如,这就是 arrays 的样子,下面的 output 是我所期望的:
a = [[],[]] ==> True
b = [["x"], ["y"], []] ==> False
假设您知道该列表仅包含其他列表(它们本身不包含列表),这是一种方法:
>>> not any(a)
True
>>> not any(b)
False
这可以工作:
for i in a:
if len(str(i))>0:
print("With Something")
else:
print("empty")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.