读书人

避免劣化的python代码 的争论

发布时间: 2012-12-21 12:03:49 作者: rapoo

避免劣化的python代码 的争议
1.xrange and enumerate

enumerate:enumerate is useful for obtaining an indexed list
xrange: generates the numbers in the range on demand. For looping, this is slightly faster than range() and more memory efficient.



根据性能比较还是xrange 好一点,如果数据量不大,用哪个都可以,哪个更符合要求您就可以使用哪个,而且enumerate和xrange同样使用的是next()方法,只是对返回数据的封装不同。

print "thanks"

读书人网 >perl python

热点推荐