摘要: 闲话少叙,python中经常会对字典的索引进行搜索判断,如判断‘user’是否为{'user1':'New Student','user2':'Old student'}的索引,本文总结了5种方法进行索引的搜索,并比较了运行时间。五种方法有:① index in dict.keys()② dict.has_key(index)③ index in dict④ index in set(dict)⑤ index in set(dict.keys())先构建一个程序运行时间的函数,用于测试。from time import clock 阅读全文
posted @ 2013-08-26 18:11 搞点儿算法 阅读(3248) 评论(2) 推荐(0) 编辑