简体   繁体   English

如何在Google Colab中替换文件

[英]How to replace files in Google Colab

This is my code to download and unzip files from google drive. 这是我从Google云端硬盘下载和解压缩文件的代码。

fileId = drive.CreateFile({'id': '1tQq-ihnTbRj6GlObBrm17Ob6j1XHHJL2'}) 
print (fileId['title'])
fileId.GetContentFile('tweets_research.zip')
!unzip tweets_research.zip -d ./

But there are already some files and I want to replace them. 但是已经有一些文件了,我想替换它们。 It is giving me this option. 它给了我这个选择。

在此处输入图片说明 But it doesn't matter whatever I press on my keyboard it's not working. 但是无论我在键盘上按什么键都没关系。

使用-o选项覆盖文件,例如,

!unzip -o tweets_research.zip -d ./

You can echo your choice as input to your command by using a pipe. 您可以使用管道将您的选择作为命令的输入。

in case of rename: 如果重命名:

!echo "r"| unzip tweets_research.zip -d ./

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM