繁体   English   中英

当 python 脚本在 Z2591C98B70119FE62489Z 脚本 BEE4

[英]Pass the variables from python script to shell script when python script is being called inside shell script

我有一个 shell 脚本 test.sh,它调用了一个 python 脚本 test.py。 这个 python 文件生成一个类似于列表类型的变量。 如何将列表变量从 python 传递到 shell 脚本之外?

通常我只是将 python 直接包含在 bash 脚本中。

test=`python -c "print('Hello world!')"`
echo $test

如果您想运行一个程序,只需让您的程序打印最终值并将 output 分配给一个变量。 所以假设你有test.py . .

print('Hello world!')

test.sh

test=`python test.py`
echo $test

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM