python找列表list中某个数对应的索引值

python找列表list中某个数对应的索引值

2023年7月26日发(作者:)

python找列表list中某个数对应的索引值⼀直以为使⽤列表解析会快⼀点,结果还没有for循环快。。。import timestart = ()for i in range(1000000): for j in range(100): w = i*jend = ()print('time is %.4f second'%(end-start))10.8520 second列表解析import timestart = ()w = [i*j for i in range(1000000) for j in range(100)]end = ()print('time is %.4f second'%(end-start))26.42 second注意,索引值index函数在array数组中不存在,所以如果⾸先是数组的话,⼀定要通过tolist()函数转换,如下:数组转列表a=()⼀维lista = [2,5,1,7]b = (7)bOut[76]: 3⼆维list

发布者:admin,转转请注明出处:http://www.yc00.com/news/1690305819a329621.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信