您可以
first在3个间隔中迭代使用for循环
import statisticsnew = [statistics.mean(first[i:i + 3]) for i in range(0, len(first), 3)]print(new) # [2, 5, 8, 11, 14, 17]

您可以
first在3个间隔中迭代使用for循环
import statisticsnew = [statistics.mean(first[i:i + 3]) for i in range(0, len(first), 3)]print(new) # [2, 5, 8, 11, 14, 17]