write down,forget
adidas eqt support ultra primeknit vintage white coming soon adidas eqt support ultra boost primeknit adidas eqt support ultra pk vintage white available now adidas eqt support ultra primeknit vintage white sz adidas eqt support ultra boost primeknit adidas eqt adv support primeknit adidas eqt support ultra boost turbo red white adidas eqt support ultra boost turbo red white adidas eqt support ultra boost turbo red adidas eqt support ultra whiteturbo adidas eqt support ultra boost off white more images adidas eqt support ultra boost white tactile green adidas eqt support ultra boost beige adidas eqt support ultra boost beige adidas eqt support refined camo drop adidas eqt support refined camo drop adidas eqt support refined running whitecamo adidas eqt support 93 primeknit og colorway ba7506 adidas eqt running support 93 adidas eqt support 93
标签 Tag : range

range与xrange的区别

<Category: Python> Comments Off on range与xrange的区别

python里的range与xrange,都可以进行用来进行迭代处理,但是两者却是不一样的,区别如下:

for x in range(100):会返回1个包含了100个整数的list对象,并进行迭代分别返回给x

for x in xrange(100):也会返回100个整数,不过没有一次返回一个集合,而是依次返回一个变量,然后赋值给x,所以也只占一个整数变量所需的内存的就行了,相对来说,由于每次都要分配内存,性能也有些影响,所以怎么使用要看情况哦。

总结,range创建代价大,消耗内存多,xrange占用内存小,每次请求的效率低一些,有点像.NET里的String和StringBuilder了

本文来自: range与xrange的区别