1
我有几个函数,我正在使用,我试图使用.split()
删除括号,但括号和引号仍然显示在输出中。我有单独的功能,因为我打算在很多不同的功能中调用fn_run_cmd
。删除输出中的括号和引号
def fn_run_cmd(*args):
cmd = ['raidcom {} -s {} -I{}'.format(list(args),
storage_id, horcm_num)]
print(cmd)
def fn_find_lun(ldev, port, gid):
result = fn_run_raidcom('get lun -port {}-{}'.format(port, gid))
return(result)
match = re.search(r'^{} +{} +\S+ +(?P<lun>\d+) +1 +{} '.format(
port, gid, ldev), result[1], re.M)
if match:
return(match.group('lun'))
return None
下面是我得到的输出:
"raidcom ['get lun -port CL1-A-2'] -s [987654] -I[99]"
期望的结果:
raidcom get lun -port CL1-A-2 -s 987654 -I99
你试过使用string.replace()方法吗? –