python基础教程笔记(1) 发表于 2016-06-16 | 分类于 Python | 遍历字典123d = {"x":1, "y":2, "z":3}for key, value in d.items(): print key, "corresponds to ", value 并行迭代12345678names = ["ych", "cpp", "ws"]ages = [12, 14, 54]>>> zip(name, ages)[("ych", 12 ), ("cpp", 14), ("ws", 54)]for name, age in zip(names, ages): print name, "is", age, "years old" 使用for循环同时迭代索引12for index, item in enumerate(some_list): print "index: ", index, "item: ", item