在Colab bash中解释时,Python字符串被破坏了

时间:2019-06-18 06:57:27

标签: python bash google-colaboratory

This question讨论了如何在Colab bash命令中使用python变量。

此命令运行正常:

ls -l "/drive/My Drive/Colab/embedding"

但是当我尝试将字符串用作变量时,

path="/drive/My Drive/Colab/embedding"


!ls -l $path

被解释为

ls -l /drive/My Drive/Colab/embedding

不带括号,结果:

  

ls:无法访问“ / drive / My”:没有这样的文件或目录   ls:无法访问“ Drive / Colab / embeddding”:没有此类文件或目录

我尝试过

!ls -l "$path"
!ls -l '$path'

但是结果是一样的。

如何使Colab将变量解释为单个字符串?

0 个答案:

没有答案