1. 为什么字典比列表查询快 首先,请看下面这段代码 1 2 3 4 5 6 7 8 9 10 11 12 13 from time import time t = time() data = [chr(i) for i in range(97, 123)] # data = dict.fromkeys(data,True) print data for i in range(9999999): after_filter = [] for find in ['aa', 'b', 'cc', 'd', 'ee']: if find not in data: after_filter.append(find) print after_filter print time() - t 直接运行: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] ['aa', 'cc', 'ee'] 24.5699999332 去