在Python中,空值通常用`None`表示。`None`是Python中的一个特殊的常量,用来表示一个空值或者没有值的情况。
if variable is None:
print("The variable is None.")
elif variable:
print("The variable is not empty.")
else:
print("The variable is empty.")
请注意,`None`与空字符串`""`、`False`、`0`、`0.0`、`0L`等是不同的,后者在某些情况下会被视为“假”(falsy),但它们并不等同于`None`。