'''
numpy.arange
numpy.arange([start, ]stop, [step, ]dtype=None)
Return evenly spaced values within a given interval.
Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). For integer arguments the function is equivalent to the Python built-in range function, but returns an ndarray rather than a list.
When using a non-integer step, such as 0.1, the results will often not be consistent. It is better to use numpy.linspace for these cases.
Parameters
start number, optional
Start of interval. The interval includes this value. The default start value is 0.
stop number
End of interval. The interval does not include this value, except in some cases where step is not an integer and floating point round-off affects the length of out.
step number, optional
Spacing between values. For any output out, this is the distance between two adjacent values, out[i+1] - out[i]. The default step size is 1. If step is specified as a position argument, start must also be given.
dtype dtype
The type of the output array. If dtype is not given, infer the data type from the other input arguments.
Returns
arangend array
Array of evenly spaced values.
For floating point arguments, the length of the result is ceil((stop - start)/step). Because of floating point overflow, this rule may result in the last element of out being greater than stop.
'''
# 作用是返回均匀分布的array,从开始到结束的数字,按照step的间隔
# 1. 生成规则是按照从start的数字开始,但是不包含stop的数字
# 2. 如果setp是整数的话,用法将会和range一样,只是一个返回的是python的list类型,一个返回的是array
# 3. 如果step是非整数的话,返回的结果经常是不稳定的,最好是使用numpy.linspace代替
#### 参数说明
# start 可选参数,默认是0,开始的数字
# stop 必选参数,结束的数字,一般情况下不包括这个数字,如果step是float的类型的话,最后结束的时候,四舍五入可能会超过这个数字
# step 可选参数,默认是1 间隔的数字,两个数字之差,如果step作为位置参数的话,start也必须给出。
# dtype 可选参数,返回的是数据的类型,如果没有指定,将会推断给出。
import numpy as np # 只使用stop这个必要参数 print(np.arange(10)) # 使用前两个参数 print(np.arange(1,8)) # 使用前三个参数 print(np.arange(1,8,3)) # 使用数据类型参数 print(np.arange(1,8,2,"float")) ''' [0 1 2 3 4 5 6 7 8 9] [1 2 3 4 5 6 7] [1 4 7] [1. 3. 5. 7.] '''