在jupyter notebook
中,我们可以使用感叹号执行shell命令,例如:
!ls *.png
我正在寻找一种将参数传递给此命令的方法,例如:
extention='*.png'
!ls %extention
我知道这可以使用 os.system或 subprocess.check_output ,但我想使用感叹号,因为这会给我实时输出。
最佳答案
这可以使用 {}
,例如:
extention='*.png'
!ls {extention}
关于python - Jupyter notebook 感叹号参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63012710/