在谷歌colab我使用以下代码将我的谷歌驱动器安装到虚拟机:

# Install a Drive FUSE wrapper.
# https://github.com/astrada/google-drive-ocamlfuse
!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse



# Generate auth tokens for Colab
from google.colab import auth
auth.authenticate_user()


# Generate creds for the Drive FUSE library.
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}


# Create a directory and mount Google Drive using that directory.
!mkdir -p My Drive
!google-drive-ocamlfuse My Drive


!ls My Drive/

# Create a file in Drive.
#!echo "This newly created file will appear in your Drive file list." > My Drive/created.txt

然后,这将安装谷歌驱动器 . 在左侧有一个文件选项卡,可用于浏览我已挂载的文件:

Image showing the file browser tab I'm referring to

但是,如果我单击十字架以折叠此侧窗口,然后再次展开它,则文件选项卡丢失,除了关闭和重新打开文档之外我不知道如何恢复它 . 这是一个错误吗?有没有办法在没有关闭和重新打开的情况下取回标签?

Image showing the file tab missing after collapsing and expanding

我发现文件选项卡非常有用,因为您可以直接从中复制路径,并执行其他活动 .

进一步但稍微不相关的问题,通过使用ocamlfuse融合驱动器我假设这实际上没有将整个驱动器上传到虚拟机?如果我想从文件夹(300 .xls或.csv文件)中读取每个文件,对它们执行一个函数并编写一个新文件,它是否更快而不是融合驱动器,以不同的方式上传文件夹,例如.zip或.tar文件?

This回答Mohamed Jihad直接使用pydrive上传.zip文件,然后将其本地存储到VM中,以便随后从中读取文件更快?