def maybe_download(url, data_dir, filename, expected_bytes, force=False):
"""
Download a file if not present, and make sure it's the right size.
"""
if force or not os.path.exists(os.path.join(data_dir, filename)):
filename, _ = urlretrieve(url + filename, os.path.join(data_dir, filename))
statinfo = os.stat(os.path.join(data_dir, filename))
if statinfo.st_size == expected_bytes:
print('Found and verified', filename)
else:
raise Exception(
'Failed to verify' + filename + '. Can you get to it with a browser?')
return filename
data_extractor.py 文件源码
python
阅读 28
收藏 0
点赞 0
评论 0
评论列表
文章目录