numpy.arange()

numpy.arange() creates an array

* Syntax: arange([start,] stop[, step,], dtype=None, , like=None)

  • start: start value, [optional], the default is 0
  • stop: stop value, [required]
  • step: step size, [optional], the default is 1
  • dtype: the format of the output array, [optional], automatically inferred by default
  • like: referencing objects to allow creation of non-NumPy arrays
import numpy as np

# 创建数组,默认从0开始,数值范围为0-9,共10个数
arr = np.arange(10) 
# 结果:[0 1 2 3 4 5 6 7 8 9]

# 创建数组,起始数值为1,终止数值为9
arr = np.arange(1,10)
# 结果:[1 2 3 4 5 6 7 8 9]

# 创建数组,起始数值范围为0-9,步长为2
arr = np.arange(0,10,2)
# 结果:[0 2 4 6 8]

Guess you like

Origin blog.csdn.net/raphero/article/details/130859922