本文实例总结了Python数组遍历的简单实现方法。分享给大家供大家参考,具体如下:
1234 | >>> os.__file__.split('')['E:', 'Python', 'Python25', 'lib', 'os.pyc']>>> os.path.split(os.__file__)('E:PythonPython25lib', 'os.pyc') |
1234 | var myArr:Array = new Array("one", "two", "three");var myStr:String = myArr.join(" and ");trace(myArr); // one,two,threetrace(myStr); // one and two and three |
1) 将每个id的属性值插入数组,Aarry.join(",") 成字符串,保存到一个txt里,或者数据库表里。(txt首选)
2) python直接解析 split(",") 成数组,索引+1是文件名,值是数据库id,读取数据库,
用enumerate函数,遍历数组,生成xml。(首选)
在Python中,我们习惯这样遍历:
12 | for item in sequence:process(item) |
这样遍历取不到item的序号i,所有就有了下面的遍历方法:
12 | for index in range(len(sequence)):process(sequence[index]) |
其实,如果你了解内置的enumerate函数,还可以这样写:
12 | for index, item in enumerate(sequence):process(index, item) |
本文
转载自: