From 82e1387dfe101fae035933a84739b401fba078d9 Mon Sep 17 00:00:00 2001 From: SteveLC Date: Thu, 12 Mar 2020 22:22:21 +0800 Subject: [PATCH] Created using Colaboratory --- GoogleDrive_Tutorial.ipynb | 158 +++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 GoogleDrive_Tutorial.ipynb diff --git a/GoogleDrive_Tutorial.ipynb b/GoogleDrive_Tutorial.ipynb new file mode 100644 index 0000000..ed9f9f3 --- /dev/null +++ b/GoogleDrive_Tutorial.ipynb @@ -0,0 +1,158 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "GoogleDrive_Tutorial.ipynb", + "provenance": [], + "collapsed_sections": [], + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ca2CpPPUvO-h", + "colab_type": "text" + }, + "source": [ + "# **Google Drive 檔案存取教學**\n", + "\n", + "作者:黃健祐 Chien-Yu Huang\n", + "\n", + "若有任何問題,歡迎來信至助教信箱 ntu-ml-2020spring-ta@googlegroups.com" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "EAM_tPQAELh0", + "colab_type": "text" + }, + "source": [ + "Colab 可以透過兩種方式存取 Google Drive 的檔案:\n", + "\n", + "**1. 透過檔案共用連結**\n", + "\n", + " 一般來說,Google Drive 的檔案連結會是類似下面的結構:\n", + "\n", + " https://drive.google.com/open?id=1duQU7xqXRsOSPYeOR0zLiSA8g_LCFzoV\n", + " \n", + " 其中 \"open?id=\" 後面的那一串亂碼稱為 **file_id**\n", + "\n", + " 在 colab 中,我們可以直接用 **file_id** 下載檔案,優點是這個過程不需要再手動輸入任何訊息,但缺點是下載下來的檔案在程式執行完畢後就會消失,也就是每一次都必須重新下載,使得執行時間增加。\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "XztYEj0oD7J3", + "colab_type": "code", + "outputId": "f1865640-0d20-4f6e-bb92-9dd047ac3ccc", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 107 + } + }, + "source": [ + "# 下載 file_id 為 \"1duQU7xqXRsOSPYeOR0zLiSA8g_LCFzoV\" 的檔案,並將它命名為 Minori.jpg\n", + "!gdown --id '1duQU7xqXRsOSPYeOR0zLiSA8g_LCFzoV' --output Minori.jpg\n", + "# 列出目前目錄下所有的檔案\n", + "!ls" + ], + "execution_count": 0, + "outputs": [ + { + "output_type": "stream", + "text": [ + "Downloading...\n", + "From: https://drive.google.com/uc?id=1duQU7xqXRsOSPYeOR0zLiSA8g_LCFzoV\n", + "To: /content/Minori.jpg\n", + "\r 0% 0.00/219k [00:00