【发布时间】:2016-12-16 16:59:59
【问题描述】:
我想从命令行调用 Jython 脚本,p.e.
$ /Applications/Fiji.app/Contents/MacOS/ImageJ-macosx --headless little_jython_script.py
我知道 Python(因此也知道 Jython)接受参数的能力
import sys
params = sys.argv[1:]
然后用类似的东西调用脚本
$ /Applications/Fiji.app/Contents/MacOS/ImageJ-macosx --headless jython_script_with_params.py param1 param2 param3.
但是,根据 ImageJ 网页 http://imagej.net/Script_parameters,也可以在 Jython 中对参数的使用进行编码,类似于该网站上的 Greeting.py 示例
# @String name
# A Jython script with parameters.
# It is the duty of the scripting framework to harvest
# the 'name' parameter from the user, and then display
# the 'greeting' output parameter, based on its type.
print "Hello, " + name + "!"
问题是:如何在命令行调用$/Applications/Fiji.app/Contents/MacOS/ImageJ-macosx --headless Helloworld.py 中指定参数name?
【问题讨论】: