主要内容摘要
- 函数参数【个人感觉难度很大,却很重要,可以先大概记一记】不要用的太复杂。戳这儿温习
- 递归函数:使用递归函数的优点是逻辑简单清晰,缺点是过深的调用会导致栈溢出。重点:找到递归关系和终止条件。可以玩玩汉诺塔
- 高级特性:
- 切片操作【区间切片&倒数切片&冒号选择性切片&】
- 迭代:
所以,当我们使用for
循环时,只要作用于一个可迭代对象,for
循环就可以正常运行,而我们不太关心该对象究竟是list还是其他数据类型。
那么,如何判断一个对象是可迭代对象呢?方法是通过collections模块的Iterable类型判断:
-
- 下标循环
-
- 列表生成式: