numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None)
在指定的间隔内返回均匀间隔的数字。
返回num均匀分布的样本,在[start, stop]。
import numpy as np #endpoint=Ture 代表包含最后的一个数(10),共输出5个数,步长为(10-0)/4 a=np.linspace(0,10,5,endpoint=True) print(a) #结果:[ 0. 2.5 5. 7.5 10. ] #endpoint=False 代表不包含最后的一个数(10),但仍然输出5个数,步长为(10-0)/5 b=np.linspace(0,10,5,endpoint=False) print(b) #结果:[0. 2. 4. 6. 8.] #共同特点是输出指定数量的数据,但步长不同。



