我在python下写了一个比较字符串的python函数如下:
import time
if name == "__main__":
fo = open("steps.txt", "r+")
steps = fo.read()
print "读取的step是 : ", steps
fo.close()
T0 = 0
X = 600
ticks = time.time()
T = (long(ticks) - T0) / X
step = str(T).upper()
while len(step) < 16:
step = "0" + step
def compare():
if steps == step:
return 1
else:
return 0
compare()
然后我想在shell脚本里调用这个compare.py获取函数return的值
代码如下:
#!/bin/bash
var1=python compare.py
echo $var1
$var1并没有输出我想看到的return值1或0,而是执行了整个py文件
我只想接受这个return值有什么好的方法吗