有人可以帮助我了解如何从shell脚本中调用'x'函数的语法。这里的挑战是,从shell脚本需要动态地传递a,b。从shell脚本中调用python函数
你的建议非常感谢。
Python代码:
def x(a,b):
'''x(a,b) --> [a,b]'''
return [a,b]
def add(a,b):
'''add(a,b) --> a+b'''
return a+b
def test():
'''test code for all modules'''
print "testing x..."
print x(1,2)
print x('a','b')
print x([1,2,3],[4,5,6])
print "testing add..."
print add(1,2)
print add('a','b')
print add([1,2,3],[4,5,6])
return
哇。在发布失败之前进行最终搜索。 –
@MadPhysicist,但答案是旧的,而不是Python3兼容 –
@JohnLaRooy这不是一个Python3的问题,* nix上的'$ python'应该总是运行python2。如果您想更新答案,请对副本进行更新。 –