How to edit and save text files (.py) in Google Colab?

后端 未结 11 1899
[愿得一人]
[愿得一人] 2020-12-24 01:16

I cloned a github repo using !git clone https://github.com/llSourcell/Pokemon_GAN.git. I wanted to modify a .py file inside Colab. So i used %load fil

11条回答
  •  旧时难觅i
    2020-12-24 01:52

    Unfortunately, it seems, colab do not support %load line magic (yet), and yet, you can see the file content using !cat your_file.py and then manually, copy the output contents, write them to a new cell and write %%writefile your_new_file_name.py at the top of the new cell to save this back to the instance. Note that, this will not be saved to your google drive yet.

    Example:
    !ls
    output: colabData/
    
    %%writefile something.py
    print("everything's fine.")
    
    !ls
    output: colabData/ something.py
    
    %run something.py
    output: everything's fine.
    

提交回复
热议问题