ez_setup.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:Adafruit_Python_ADS1x15 作者: adafruit 项目源码 文件源码
def download_file_insecure(url, target):
    """
    Use Python to download the file, even though it cannot authenticate the
    connection.
    """
    try:
        from urllib.request import urlopen
    except ImportError:
        from urllib2 import urlopen
    src = dst = None
    try:
        src = urlopen(url)
        # Read/write all in one block, so we don't create a corrupt file
        # if the download is interrupted.
        data = src.read()
        dst = open(target, "wb")
        dst.write(data)
    finally:
        if src:
            src.close()
        if dst:
            dst.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号