摘要: def timer(f): #闭包,这里闭包的不是变量,而是形参f def inner(): print("执行函数前") f() print("执行函数后") return inner@timerdef func(): print('hello ,装饰器') time.sleep(0.1)f1=f 阅读全文
posted @ 2019-09-09 10:06 wxl106 阅读(115) 评论(0) 推荐(0) 编辑
摘要: # 指定数的阶乘def sum(n): if n==1: return n else: return n*sum(n-1)num=sum(5)print(num) # 阶乘递归求和def total_sum(m): total=0 for i in range(1,m+1): def sum(n): 阅读全文
posted @ 2019-09-09 09:30 wxl106 阅读(327) 评论(0) 推荐(0) 编辑