Python Bash命令自动下载一个压缩文件夹-googlecolab

Python Bash命令自动下载一个压缩文件夹-googlecolab,python,bash,google-colaboratory,Python,Bash,Google Colaboratory,我无法运行!zip..行(见下文)在google Colab上自动显示。 因此,我编写了一个代码段来创建一个完整的字符串,然后在另一个单元格中运行它。 我已经尝试了exec(…code..)和os.system(),但都不起作用 parent_dir = "/content/" folder = "WS_Epids" dir = parent_dir+folder zipped = dir+".zip" to_download = &

我无法运行
!zip..
行(见下文)在google Colab上自动显示。 因此,我编写了一个代码段来创建一个完整的字符串,然后在另一个单元格中运行它。 我已经尝试了
exec(…code..)
os.system()
,但都不起作用

parent_dir = "/content/"
folder = "WS_Epids"
dir = parent_dir+folder

zipped = dir+".zip"
to_download = "\nfrom google.colab import files\nfiles.download('%s')"%zipped
bash_string = "!zip -r "+zipped+" "+dir+to_download #!zip -r /opt.zip /opt
print(bash_string)
哪张照片

!zip -r /content/WS_Epids.zip /content/WS_Epids
from google.colab import files
files.download('/content/WS_Epids.zip')
我需要粘贴到另一个单元格中并运行。 有没有可能使这一切自动化