摘要: import random from timewrap import cal_time # 一个计算时间的装饰器 def merge(li, low, mid, high): i = low j = mid + 1 li_tmp = [] while i <= mid and j <= high: if li[i] <= li[j]: ... 阅读全文
posted @ 2018-12-15 18:03 小学弟- 阅读(174) 评论(0) 推荐(0) 编辑
摘要: python自带模块 阅读全文
posted @ 2018-12-15 17:59 小学弟- 阅读(207) 评论(0) 推荐(0) 编辑
摘要: def hanoi(n, A, B, C): if n > 0: hanoi(n-1, A, C, B) print("%s->%s" % (A, C)) hanoi(n-1, B, A, C) hanoi(4, 'A', 'B', 'C') 阅读全文
posted @ 2018-12-15 13:32 小学弟- 阅读(958) 评论(0) 推荐(0) 编辑
摘要: import time def cal_time(func): def wrapper(*args, **kwargs): t1 = time.time() result = func(*args, **kwargs) t2 = time.time() print("%s running time: %s secs." ... 阅读全文
posted @ 2018-12-15 13:32 小学弟- 阅读(386) 评论(0) 推荐(0) 编辑