生成包含一系列等间距值的动态数组。Generates a dynamic array holding a series of equally-spaced values.


range(start, stop[, step]) range(start, stop [, step ])


  • start :生成数组中第一个元素的值。start : The value of the first element in the resulting array.
  • stop:生成数组中最后一个元素的值,或大于生成数组中的最后一个元素且在 start 中 step 的整数倍以内的最小值。stop : The value of the last element in the resulting array, or the least value that is greater than the last element in the resulting array and within an integer multiple of step from start .
  • step:数组中两个连续元素之间的差异。step : The difference between two consecutive elements of the array. step 的默认值为 1(数字)和 1htimespandatetimeThe default value for step is 1 for numeric and 1h for timespan or datetime


以下示例返回 [1, 4, 7]The following example returns [1, 4, 7]:

T | extend r = range(1, 8, 3)

以下示例返回包含 2015 年所有天数的数组:The following example returns an array holding all days in the year 2015:

T | extend r = range(datetime(2015-01-01), datetime(2015-12-31), 1d)

以下示例返回 [1,2,3]The following example returns [1,2,3]:

range(1, 3)

以下示例返回 ["01:00:00","02:00:00","03:00:00","04:00:00","05:00:00"]The following example returns ["01:00:00","02:00:00","03:00:00","04:00:00","05:00:00"]:

range(1h, 5h)