get return value of python in shell

from: https://*.com/questions/2115615/assigning-value-to-shell-variable-using-a-function-return-value-from-python

def foo_fun():
return "some string"
#return 10 .. alternatively, it can be an int if __name__ == "__main__"
  print foo_fun() # or sys.stdout.write("%s" % foo_fun())

shell

fooShell=$(python fooPy.py)
echo $fooShell

输出:

“some string”

上一篇:chm只看到目录,看不到内容解决办法


下一篇:Java知多少(5) Java开发环境的搭建