2016-03-06 89 views
0

運行python功能這是我的shell腳本,我想要運行的方法foo(param)如何從shell腳本

#!/bin/sh  
python /Users/username/Desktop/forTrump/test.py 

我將如何運行使用上面的shell腳本里面test.py的功能?

+2

的[調用從一個外殼腳本Python函數(http://stackoverflow.com/questions/8567526/calling-a-python-function-from-a-shell-script) – mishik

回答

1
python -c 'import test; print test.foo(param)' 
+0

如果可能的複製你對答案滿意,你可以將它標記爲已回答 –

+1

請開始以解釋的方式寫出半途而廢的答案,而不僅僅是代碼轉儲,並停止讓討厭的OP接受。 – jonrsharpe

+0

我想在絕對路徑爲「/Users/username/Desktop/forTrump/test.py」的shell腳本中運行此操作我不打印任何只運行該方法的文件,該文件將運行至文件,如果仍包含「打印」? – Sorry