如何显示隐藏文件colab

how to show hidden files colab

我在 python3 如何查看或显示隐藏文件

上使用 colab

就像这张图片一样,我看不到隐藏文件(.files)

在googlecolab环境下,如果满足您的需要,以下命令可以在控制台模式下以不同的方式显示所有文件,包括隐藏文件(长列表格式)。

!ls -al

同时,一个笨拙的解决方法是使用 !cp 将文件复制到您的 google 驱动器存储(如果您有),进行更改并将它们复制回来。示例:

from google.colab import drive
drive.mount("/content/gdrive")
%cd /root 
%ls -a
 >   .cache/     .gsutil/   .local/   .tmux.conf* ... .bashrc* ...
!cp /root/.bashrc* /content/gdrive/folder
#make changes on bashrc and copy back
!cp /content/gdrive/folder/.bashrc /root/.bashrc

因为我使用 colab-ssh + github + vscode 我可以浏览 vscode 中的所有文件夹和文件并在那里进行更改。但是这个设置需要一些准备工作。
更快的方法是注册一个免费的 ngrok 帐户,复制 authtoken 和 运行 以下命令:

!pip install colabcode
from colabcode import ColabCode
ColabCode(password="anything", authtoken="your token")
.
.
.
Code Server can be accessed on: NgrokTunnel: "https://8348-34-125-56-97.ngrok.io" -> "http://localhost:10000"
[2022-03-31T08:01:58.749Z] info  code-server 3.10.2 387b12ef4ca404ffd39d84834e1f0776e9e3c005
[2022-03-31T08:01:58.751Z] info  Using user-data-dir ~/.local/share/code-server
..
..

单击 ngrok.io link 后,您必须输入密码。编辑器打开后,您可以单击“打开文件夹”,选择基础“/”文件夹。您可以在那里浏览所有文件并直接在编辑器界面中进行更改:

现在他们更新了 带有表示隐藏物品的眼睛符号的网站