python 迭代器 要理解python迭代器(iterator),先要理解两个概念:Iterable(可迭代对象).Iterator(迭代器) 先来help()一下Iterator: >>> help(Iterator) Help on class Iterator in module collections.abc: class Iterator(Iterable) | Method resolution order: | Iterator | Iterable | builtins…
#python 学习笔记 2017/07/13 # !/usr/bin/env python3 # -*- conding:utf-8 -*- #从高阶函数的定义,我们可以知道,把函数作为参数的函数,把函数作为返回值的参数都是高阶函数 #可变参数求和 def calc_sum(*args): sum = 0 for n in args: sum = sum + n return sum #这个函数会立即返回求和结果,如果不要立即返回求和结果,而是需要在计算,可以返回求和函数,当再次调用时才给出计…
#python学习笔记 17/07/10 # !/usr/bin/evn python3 # -*- coding:utf-8 -*- import math #函数 函数的 定义 #定义一个求绝对值函数 def abstruct(a): if not isinstance (a, (int, float)): raise TypeError("param must be a int or float type") if a >= 0: return a else: return…
1.list can hold arbitrary objects and can expand dynamically as new items are added. A list is an ordered set of items. 2.A tuple is an immutable list. A tuple can not be changed in any way once it is created. 3.A set is an unordered “bag” of…