当我从 shell 脚本调用 python 文件时,如何获取带有路径打印的 python 文件的变量?

How can I get the variable that a python file with a path prints when I call that python file from a shell script?

出于某种原因,当我 运行 在我的 shell 脚本中只有 $exec_file 和 $_dir 被传递到 module_test.py,但 $filename 和 $modified_file 通过。

mod_test=$( /path/module_test.py $modified_file $_dir $filename )

(路径只是为了这个例子我决定缩短的正常路径) 我打错了吗?我正在尝试将 module_test.py 的输出(整数)放入变量 mod_test.

我的变量是:

modified_file = _File
_dir = /path to directory/
file = _File.py

根据您的示例,您需要用引号将 $_dir 括起来,因为它包含空格,即:

mod_test=$( /path/module_test.py $modified_file '$_dir' $filename )