在google colab中下载kaggle数据集

!pip install kaggle
api_token = {"username":"lky190249","key":"8e5bafa71ffe555c3fe75749523743c2"}
import json
import zipfile
import os
with open('/root/.kaggle/kaggle.json', 'w') as file:
    json.dump(api_token, file)
!kaggle datasets download -d iarunava/happy-house-dataset
if not os.path.exists("/content/competitions/happy-house-dataset"):
    os.makedirs("/content/competitions/happy-house-dataset")
os.chdir('/content/competitions/happy-house-dataset')
for file in os.listdir():
    zip_ref = zipfile.ZipFile(file, 'r')
    zip_ref.extractall()
    zip_ref.close()

参考链接:https://gist.github.com/jayspeidell/d10b84b8d3da52df723beacc5b15cb27

posted @ 2019-06-21 14:00  洋洋同学  阅读(1824)  评论(0编辑  收藏  举报