时间:1个小时左右
代码:200行左右
博客:1
知识点:Python的列表添加的效率
import timeit num_list = [12, 34, 56, 78, '如花'] num1 = {77, 88, 99} def func1(): num_list.append("似玉") def func2(): num_list.insert(len(num_list), "似玉") def func3(): num_list.extend(num1) t1 = timeit.timeit(stmt=func1, number=1000) t2 = timeit.timeit(stmt=func2, number=1000) t3 = timeit.timeit(stmt=func3, number=1000) print(t1) print(t2) print(t3)