0%
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
import time
start_1 = time.time() def print_n(n): for i in range(n): print(i+1) print_n(9) print('循环用时:%d 秒'%(time.time()-start_1))
start_2 = time.time() def print_N(n): if n: print_N(n-1) print('第%d层递归是%d'%(n,n)) print_N(9) print('递归用时:%d 秒'%(time.time()-start_2))
|