首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

避免劣化的python代码 的争论

2012-12-21 
避免劣化的python代码 的争议1.xrange and enumerateenumerate:enumerate is usefulfor obtaining an inde

避免劣化的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"

热点排行