我希望能够以下列方式从 shell 命令行启动 python 脚本:
python script_name -temp=value1 -press=value2
我是这样写的:
#!/usr/bin/python
import sys
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("temp", help="specify the temperature [K]", type=float)
parser.add_argument("press", help="specify the pressure [Pa]", type=float)
args = parser.parse_args()
temp = args.temp
press = args.press
print temp
print press
输入可以是:
python script_name value1 value2
如何能够以 -arg=value 的方式输入值?