它类似于排列功能。但是,它不允许我们在语法中指定步长。
取而代之的是,它仅返回指定时间段内均匀分隔的值。系统隐式计算步长。
numpy.linspace(start, stop, num, endpoint, retstep, dtype)
它接受以下参数。
返回指定范围内的数组。
import numpy as np arr = np.linspace(10, 20, 5) print("The array over the given range is ",arr)
输出:
The array over the given range is [10. 12.5 15. 17.5 20.]
import numpy as np arr = np.linspace(10, 20, 5, endpoint = False) print("The array over the given range is ",arr)
输出:
The array over the given range is [10. 12. 14. 16. 18.]
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)
Tony Bai · Go语言第一课 -〔Tony Bai〕