您好,我如何使用bash从文件系统中读取json并将字符串作为参数传递给python脚本? 我试过了但这不起作用
config=`cat test.json | tr '\n' ' '`
python3 script.py\
--config $config \
答案 0 :(得分:2)
为什么要消除换行符?
python3 script.py --config "$(<test.json)"
或者如果您真的需要它们,
python3 script.py --config "$( tr "\n" ' ' < test.json)"