html网站模板下载,中网可信网站查询,网站页面关键词优化,三只松鼠建设网站前的市场分析菜鸟教程《Python 3 教程》笔记#xff08;15#xff09; 15 数据结构15.1 将列表当作队列使用15.2 遍历技巧 笔记带有个人侧重点#xff0c;不追求面面俱到。 15 数据结构
出处#xff1a; 菜鸟教程 - Python3 数据结构
15.1 将列表当作队列使用 在列表的最后添加或者弹… 菜鸟教程《Python 3 教程》笔记15 15 数据结构15.1 将列表当作队列使用15.2 遍历技巧 笔记带有个人侧重点不追求面面俱到。 15 数据结构
出处 菜鸟教程 - Python3 数据结构
15.1 将列表当作队列使用 在列表的最后添加或者弹出元素速度快然而在列表里插入或者从头部弹出速度却不快因为所有其他的元素都得一个一个地移动。 15.2 遍历技巧
遍历字典 knights {gallahad: the pure, robin: the brave}for k, v in knights.items():
... print(k, v)
...
gallahad the pure
robin the brave遍历列表 for i, v in enumerate([tic, tac, toe]):
... print(i, v)
...
0 tic
1 tac
2 toe遍历多个序列 questions [name, quest, favorite color]answers [lancelot, the holy grail, blue]for q, a in zip(questions, answers):
... print(What is your {0}? It is {1}..format(q, a))
...
What is your name? It is lancelot.
What is your quest? It is the holy grail.
What is your favorite color? It is blue.反向遍历 for i in reversed(range(1, 10, 2)):
... print(i)
...
9
7
5
3
1