在Python中,判断一个数组(列表)是否为空,你可以使用以下方法:
1. 使用 `len()` 函数:
```python
my_list = []
if len(my_list) == 0:
print("数组为空")
else:
print("数组不为空")
2. 使用布尔表达式 `not`:
```python
my_list = []
if not my_list:
print("数组为空")
else:
print("数组不为空")
3. 使用 `bool()` 函数:
```python
my_list = []
if bool(my_list) == False:
print("数组为空")
else:
print("数组不为空")
以上方法都可以用来判断Python中的列表是否为空。请选择适合你需求的方法使用