在Python中,可以使用以下几种方法求平均值:
numbers = [1, 2, 3, 4, 5]
average = sum(numbers) / len(numbers)
print(average)
import statistics
numbers = [1, 2, 3, 4, 5]
average = statistics.mean(numbers)
print(average)
import numpy as np
numbers = [1, 2, 3, 4, 5]
average = np.mean(numbers)
print(average)
以上是三种常见的方法求平均值,具体使用哪种方法取决于个人偏好和项目需求。