当前位置: 首页 > news >正文

水文站网站建设应当坚持单位网站建设费算无形资产吗

水文站网站建设应当坚持,单位网站建设费算无形资产吗,使用帝国做软件下载网站源码,新开传奇网站刚开一秒第一区使用Python分析数据#xff0c;如果使用了正确的数据结构和算法#xff0c;有时可以大量提高程序的速度。实现此目的的一种方法是使用Muiltithreading(多线程)或Multiprocessing(多重处理)。 使用Python分析数据#xff0c;如果使用了正确的数据结构和算法#xff0c;有时可…使用Python分析数据如果使用了正确的数据结构和算法有时可以大量提高程序的速度。实现此目的的一种方法是使用Muiltithreading(多线程)或Multiprocessing(多重处理)。 使用Python分析数据如果使用了正确的数据结构和算法有时可以大量提高程序的速度。实现此目的的一种方法是使用Muiltithreading(多线程)或Multiprocessing(多重处理)。 在这篇文章中我们不会详细讨论多线程或多处理的内部原理。相反我们举一个例子编写一个小的Python 脚本从Unsplash下载图像。我们将从一次下载一个图像的版本开始。接下来我们使用线程来提高执行速度。Python中多线程和多处理的初学者指南 多线程 简单地说线程允许您并行地运行程序。花费大量时间等待外部事件的任务通常适合线程化。它们也称为I/O Bound任务例如从文件中读写网络操作或使用API在线下载。让我们来看一个示例它展示了使用线程的好处。 1. 没有线程 在本例中我们希望通过顺序运行程序来查看从Unsplash API下载15张图像需要多长时间 import requests import time img_urls [ https://images.unsplash.com/photo-1516117172878-fd2c41f4a759, https://images.unsplash.com/photo-1532009324734-20a7a5813719, https://images.unsplash.com/photo-1524429656589-6633a470097c, https://images.unsplash.com/photo-1530224264768-7ff8c1789d79, https://images.unsplash.com/photo-1564135624576-c5c88640f235, https://images.unsplash.com/photo-1541698444083-023c97d3f4b6, https://images.unsplash.com/photo-1522364723953-452d3431c267, https://images.unsplash.com/photo-1513938709626-033611b8cc03, https://images.unsplash.com/photo-1507143550189-fed454f93097, https://images.unsplash.com/photo-1493976040374-85c8e12f0c0e, https://images.unsplash.com/photo-1504198453319-5ce911bafcde, https://images.unsplash.com/photo-1530122037265-a5f1f91d3b99, https://images.unsplash.com/photo-1516972810927-80185027ca84, https://images.unsplash.com/photo-1550439062-609e1531270e, https://images.unsplash.com/photo-1549692520-acc6669e2f0c ] start time.perf_counter() #start timer for img_url in img_urls: img_name img_url.split(/)[3] #get image name from url img_bytes requests.get(img_url).content with open(img_name, wb) as img_file: img_file.write(img_bytes) #save image to disk finish time.perf_counter() #end timer print(fFinished in {round(finish-start,2)} seconds) #results Finished in 23.101926751 seconds 一共用时23秒。 2. 多线程 让我们看看Pyhton中的线程模块如何显著地改进我们的程序执行 import time from concurrent.futures import ThreadPoolExecutor def download_images(url):img_name img_url.split(/)[3] img_bytes requests.get(img_url).content with open(img_name, wb) as img_file: img_file.write(img_bytes) print(f{img_name} was downloaded) start time.perf_counter() #start timer with ThreadPoolExecutor() as executor:results executor.map(download_images,img_urls) #this is Similar to map(func, *iterables) finish time.perf_counter() #end timer print(fFinished in {round(finish-start,2)} seconds) #results Finished in 5.544147536 seconds 我们可以看到与不使用线程代码相比使用线程代码可以显著提高速度。从23秒到5秒。 对于本例请注意在创建线程时存在开销因此将线程用于多个API调用是有意义的而不仅仅是单个调用。 此外对于密集的计算如数据处理图像处理多处理比线程执行得更好。
http://www.yutouwan.com/news/13149/

相关文章:

  • 招商网站办公家具 技术支持 东莞网站建设
  • 临沂建设质量监督站网站网站建设需要哪些常用技术
  • 抚松网站建设灵台门户网站建设
  • 有什么网站是专做婚礼素材的南京江宁网站制作
  • editplus怎么创网站电商运营网站设计
  • 医疗网站建设机构分类导航wordpress
  • 安徽做网站找谁怎么上传图片到公司网站
  • 零基础 网站百度指数怎么用
  • 建筑公司网站设计模板商城网站免费建设
  • 网站开发的问题企业管理专业大学排名
  • 乐山旅游 英文网站建设网站a记录吗
  • 绍兴专业制作网站做商业广告有什么网站好推销的
  • 山西网站推广公司广州做网站好的公司
  • 虚拟主机 多个网站vue做网站如何优化seo
  • 网站建设后怎么写成都个人建网站
  • 网站专题页策划白银网站网站建设
  • 网站开发区网页设计与制作课程大纲
  • 美食网站开发做网站模板用什么软件
  • 百度建网站多少钱万江区仿做网站
  • 各大网站logo图标网站ip和uv
  • 庆阳门户网站网址大全下载安装
  • 网站负责人照片最好大连网站建设
  • 什么是网站外链php网站开发流程
  • 企业网站建设预算网站图标做多大好
  • 湛江专业建站联系方式网架公司联系方式
  • 网站内搜索wordpress删除边栏
  • wordpress网站菜单固定免费标志在线设计
  • 青年文明号网站建设vs2013 手机网站开发
  • 做导购网站有哪些互联网推广品牌
  • 公司网站建设怎么选择主机大小海南景区网站建设方案