问候 当我尝试将参数放入我的 python 脚本时收到错误消息。这是功能
from optparse import OptionParser
def getparams():
usage = "usage: %prog -d <dcb_ip> -p <port> "
parser = OptionParser(usage)
parser.add_option("-d", "--dcb_ip",
action="store",
dest="dcb_ip",
default="172.14.20.31",
help="Specifiy the IP address of the device, default is [%default].")
parser.add_option("-p", "--port",
action="store",
type="int",
dest="port",
default=51500,
help="Specify the pcl port of the monitor, default is [%default].")
parser.add_option("-i", "--interactive", action="store_true", default=False, dest="interactive")
parser.add_option("-l", "--loop", action="store", default=False, dest="loop")
parser.add_option("-w", "--write", action="write_mem", default=False, dest="interactive") #Write HART option
parser.add_option("-r", "--read", action="read_mem", default=False, dest="interactive")
parser.add_option("-c", "--Cancel", action="cancel_mem", default=False, dest="interactive")
(options, args) = parser.parse_args(sys.argv)
return options
有谁知道为什么我一直得到
Traceback (most recent call last):
File "C:\Users\Documents\devices_15_JUL_2013\RSimulator.py", line 73, in getparams
parser.add_option("-w", "--write", action="write_mem", default=False) #Write mem option
OptionError: option -w/--write: invalid action: 'write_mem''
我认为 -c 可能是一个常见的选项或其他东西,但即使我改变了它仍然不起作用:(