我会将其打印到命令行中选择的文件中,然后使用类似的形式在bash中获取该值
cat。
所以你会去:
python b.py tempfile.txtvar=`cat tempfile.txt`rm tempfile.txt
[编辑,另一个基于其他答案的想法]
您的另一种选择是仔细格式化输出,以便可以使用bash函数(例如
head/)
tail仅将第一行/最后一行输入到下一个程序中。

我会将其打印到命令行中选择的文件中,然后使用类似的形式在bash中获取该值
cat。
所以你会去:
python b.py tempfile.txtvar=`cat tempfile.txt`rm tempfile.txt
[编辑,另一个基于其他答案的想法]
您的另一种选择是仔细格式化输出,以便可以使用bash函数(例如
head/)
tail仅将第一行/最后一行输入到下一个程序中。