问题
I'm trying to delete a file that I uploaded on Google colab using the following code:
from google.colab import files
uploaded = files.upload()
How to delete the file now? e.g If the file's name is 'sample.jpg' .
回答1:
Try this
!rm sample.jpg
Then check that it is gone with !ls -al
Update (nov 2018) Now you can click to open left pane, browse the files tab, then right click to select and delete a file.
回答2:
Answer from @Korakot works for a single file and in case, to delete entire folder or subfolders or files
use
!rm -rf <folder_name>
回答3:
In the menu in Google Collab chose Runtime->Restart all runtimes. This will clear up all your file uploads.
回答4:
you can see available data or files through !ls
then use !rm for delete
> from google.colab import files
>
> !ls
>
> !rm data.csv
example image
回答5:
To delete a folder which has multiple folders, use:
%rm -rf <folder_name>
来源:https://stackoverflow.com/questions/52265978/how-to-delete-a-locally-uploaded-file-on-google-colab