Python 列表如何计算平均值 (mean)
Python 中的列表(list)没有内置的'mean'函数,但是可以使用 numpy 库中的'mean'函数来计算列表的平均值。例如:
import numpy as np
my_list = [1, 2, 3, 4, 5]
mean = np.mean(my_list)
print(mean) # 输出 3.0
原文地址: https://www.cveoy.top/t/topic/npnB 著作权归作者所有。请勿转载和采集!
安全问答是一个知识全球问答,包含丰富的问答知识
Python 中的列表(list)没有内置的'mean'函数,但是可以使用 numpy 库中的'mean'函数来计算列表的平均值。例如:
import numpy as np
my_list = [1, 2, 3, 4, 5]
mean = np.mean(my_list)
print(mean) # 输出 3.0
原文地址: https://www.cveoy.top/t/topic/npnB 著作权归作者所有。请勿转载和采集!