Jupyter笔记本感叹号参数

时间:2020-07-21 10:39:41

标签: python jupyter-notebook

jupyter notebook中,我们可以使用感叹号执行shell命令,例如:

!ls *.png

我正在寻找一种将参数传递给该命令的方法,例如:

extention='*.png'
!ls %extention

我知道可以使用os.systemsubprocess.check_output,但是我想使用感叹号,因为这会给我实时输出。

1 个答案:

答案 0 :(得分:1)

可以使用{},例如:

extention='*.png'
!ls {extention}