06 2018 档案
摘要:一、递归的定义 递归调用是函数嵌套调用的一种特殊形式,在函数调用时,直接或间接的调用了它本身,就是递归调用。 直接调用函数本身 def f1(): print('from f1') f1() f1() 间接调用函数本身 def f1(): print('from f1') f2() def f2()
阅读全文
摘要:#把列表推导式的[]换成()就是生成器表达式 #示例:把生一筐鸡蛋变成给你一只老母鸡,这也是生成器的特性 chicken=('鸡蛋%s' %item for item in range(10)) print(chicken) #生成器对象内存地址 print(next(chicken)) #鸡蛋0
阅读全文
摘要:l1=[] for item in range(10): l.append(item**2) print(l1) l2=[item**2 for item in range(10)] print(l2) l1=l2
阅读全文
摘要:x=10 y=20 res=x if x > y else y print(res) #res=20
阅读全文
浙公网安备 33010602011771号