给定以下 Python 代码:
def avg(a):
if len(a):
return sum(a) / len(a)
a 的长度为零时 avg 的语言定义行为是什么,或者它的行为未被语言指定,因此不应在 Python 代码中依赖?
请您参考如下方法:
默认返回值为None。
A call always returns some value, possibly
None, unless it raises an exception. How this value is computed depends on the type of the callable object.
