cxccat.py 文件源码

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

项目:supernovae 作者: astrocatalogs 项目源码 文件源码
def download_file(url, path, overwrite=False):
    local_filename = url.split('/')[-1]
    # NOTE the stream=True parameter
    local_path = os.path.join(path, local_filename)
    if os.path.isfile(local_path) and not overwrite:
        return local_path
    r = requests.get(url, stream=True)
    with open(local_path, 'wb') as f:
        for chunk in r.iter_content(chunk_size=1024): 
            if chunk: # filter out keep-alive new chunks
                f.write(chunk)
                #f.flush() commented by recommendation from J.F.Sebastian
    return local_path
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号