要使用shell获取Python返回值,可以使用以下两种方法:
result=`python script.py`
echo "The result is: $result"
result=$(python script.py)
echo "The result is: $result"
在这两种方法中,python script.py
表示要执行的Python脚本。将其替换为实际的Python脚本文件名或命令。在shell脚本中,可以使用$result变量来引用Python返回的值。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:shell如何获取python返回值