How to use Python variables in Google Colab terminal command?

前端 未结 1 727
野趣味
野趣味 2021-02-07 06:16

I have a cell with this content:

import os
os.mkdir(\'123\')
name = \'123\'
!rm -r name

I want to pass the value of the variable name

相关标签:
1条回答
  • 2021-02-07 06:53

    Try $. It will substitute the python variable.

    !rm -r $name
    

    You may need to use $name\.txt or {name}.txt in some cases.

    0 讨论(0)
提交回复
热议问题