定义一个函数,该函数可通过参数接收一个列表,在函数中计算列表数据的平均值并返回结果,通过调用函数进行测试。
from numpy import mean def average(x): return mean(x) t = [1, 2, 3, 4] print(average(t))