Python | statistics 发表于 2020-05-30 分类于 Python 阅读次数: Valine: statistics median() 求中位数 1234lst = [2, 3, 2, 3, 5, 6, 8]from statistics import medianmedian(lst)# 3 median_high() 当元素个数为偶数时,求中位数,返回中间两个元素的较大的那个作为中位数 123456lst = [2, 3, 2, 3, 5, 6, 8, 10]import statistics as ss.median(lst)# 4.0s.median_high(lst)# 5 median_low() 当元素个数为偶数时,求中位数,返回中间两个元素的较小的那个作为中位数 123456lst = [2, 3, 2, 3, 5, 6, 8, 10]import statistics as ss.median(lst)# 4.0s.median_low(lst)# 3 参考资料 统计模块:Python3.7的statistics模块 Thank you for your approval. 打赏 支付宝 微信支付 WeChat Bezahlung 欢迎关注我的其它发布渠道 WeChat