RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
Python中list查询及所需时间计算操作示例-创新互联

本文实例讲述了Python中list查询及所需时间计算操作。分享给大家供大家参考,具体如下:

创新互联公司主要从事做网站、网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务孟州,10余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220
# -*-coding=utf-8 -*-
#! python2
#filename: list_query
#date: 2018-03-25
#author: guosw
import time
def cost_time(fun):
  def cost(*args,**kwargs):
    stime = time.time()
    x = fun(*args,**kwargs)
    etime = time.time()
    print "function name:",fun.__name__
    print "time cost:",etime-stime
    return x
  return cost
@cost_time
def list_query(_list,_val):
  low = 0
  height = len(i) - 1
  mid = (height - low) // 2
  for n in xrange(height+1):
    if _list[n] == _val:
      return n
  for n in xrange(mid,height+1):
    if _list[n] == _val:
      return n
if __name__ == "__main__":
  i = xrange(100000)
  subscript = list_query(i,9999)
  print subscript

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页标题:Python中list查询及所需时间计算操作示例-创新互联
URL网址:http://scyingshan.cn/article/cooeeg.html