我是Python的新手。我正在创建一个Python脚本,它返回一个字符串“hello world”。同时我也在创建一个Shell脚本,并从Shell中调用Python脚本。
- 我需要从Shell传递参数给Python。
- 我需要在Shell脚本中打印从Python返回的值。
这是我的代码:
shellscript1.sh
#!/bin/bash
# script for testing
clear
echo "............script started............"
sleep 1
python python/pythonScript1.py
exit
pythonScript1.py
#!/usr/bin/python
import sys
print "Starting python script!"
try:
sys.exit('helloWorld1')
except:
sys.exit('helloWorld2')