gpt4 book ai didi

python - Jupyter notebook 感叹号参数

转载 作者:行者123 更新时间:2023-12-05 09:08:48 31 4
gpt4 key购买 nike

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

!ls *.png

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

extention='*.png'
!ls %extention

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

最佳答案

这可以使用 {},例如:

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

关于python - Jupyter notebook 感叹号参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63012710/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com