Python的range(n)的用法

Python的range(n) 方法就是:

API定义:  If you do need to iterate(迭代) over a sequence(一系列) of numbers, the built-in function range() comes in handy(方便的). It generates arithmetic progressions

  如果确实需要迭代一组数字,那么内置函数range()就派上用场了。它生成算术级数。

个人:就是range(数字n),获取长度为数字n的tuple(元组)集合,可以通过list(tup)将元组转为list列组

例如:

1 range(10)表示: range(0, 10)
2 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

    

猜你喜欢

转载自www.cnblogs.com/zl520/p/9927752.html
今日推荐