将我的文件保存在共享驱动器Google colab中

时间:2020-02-13 11:21:13

标签: python-3.x google-colaboratory

我们正在以共享驱动器的形式工作,我们正在使用Google Colab支持我们的代码。

这是路径:/ content / drive /共享驱动器/ Projet_IE / Technique / BDD

我们希望将文件(.json)保存在驱动器中,但由于“共享驱动器”中的空白而失败

由于GDrive强加了“共享驱动器”,并且代码不理解该路径中的空白,因此我们如何使该路径对于代码而言是可理解的?

谢谢!

1 个答案:

答案 0 :(得分:0)

from google.colab import drive
import json
!mkdir -p /content/gdrive/My\ Drive/test
a = {'a':1,'b':2,'c':3}
with open("/content/gdrive/My Drive/test/your_json_file", "w") as fp:
    json.dump(a , fp)