zoukankan      html  css  js  c++  java
  • record-11 网络编程 下载

    from time import time,sleep
    
    now1=time()
    
    #import urllib.request
    #urllib.request.urlretrieve()
    
    #from urllib import request
    #request.urlretrieve()
    
    def abc1(a,b,c):
        print(a) #a接收的是下载过程中数据包的序号
        print(b) #b接收的是下载过程中每个数据包的大小
        print(c) #c接收的是下载的总资源大小
    
    def abc2(a,b,c):
        global now1
        now2=time()
        result=(a+1)*b/c
        if now2-now1>5:
            print('当前下载进度%.2f%%'%result)
            now1=now2
    
    from urllib.request import urlretrieve
    #urlretrieve() #下载网络资源
    #第一个参数是URL 协议声明+IP/域名+端口+资源路径
    #第二个参数是本地保存路径
    #第三个参数是函数,要求这个函数必须有三个形参
    
    url='https://www.python.org/ftp/python/3.6.4/python364.chm'
    path='D:\python364.chm'
    
    urlretrieve(url,path,abc2)
    

      

  • 相关阅读:
    函数
    数组
    类的例题
    异常语句
    类的学习
    for的穷举、迭代
    for循环
    switch case
    反相器,扇入扇出
    T触发器,JK触发器的verilog实现
  • 原文地址:https://www.cnblogs.com/minkillmax/p/8313140.html
Copyright © 2011-2022 走看看