我真的很喜欢 jupyter 像这样内联混合 bash 命令的能力:
for d in list_of_dirs:
! ls {d}
但是,有什么方法可以将这些内联命令之一的输出分配给 python 变量?例如作为 python 列表?
最佳答案
是这样的吗?
代码:
python_list = []
for d in list_of_dirs:
temp_list = !ls {d}
python_list.extend(temp_list)
关于python - Jupyter 单行 bash 到 python 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55599510/