试图将参数传递给子系统,但正在输出制表符

2024-05-29 01:49:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试传递一个参数,该参数允许使用syslog进行详细日志记录。将-v传递给应用程序肯定能按预期工作。所以我尝试将此选项添加到json配置文件中。你知道吗

以下是json配置中的内容:

"rtl": {
            "freq": 144.390,
            "ppm": -3,
            "gain": 44.5,
            "debug": true,
            "offset_tuning": false,
            "device_index": 0,
    },

这是我的密码。注意:除了我添加-v语句外,其他所有部分都工作。你知道吗

if self.config['source'] == 'rtl':
   proc_src = subprocess.Popen(
   ['rtl_fm', '-f', str(int(self.config['rtl']['freq'] * 1e6)), '-s', '22050',
   '-v', str(self.config['rtl'].get('debug', 'true')), '-v'],,
   '-p', str(self.config['rtl']['ppm']), '-g', str(self.config['rtl']['gain']),
   '-E', 'offset' if self.config['rtl'].get('offset_tuning', False) else 'none',
   '-d', str(self.config['rtl'].get('device_index', 0)), '-'],
   stdout=subprocess.PIPE, stderr=open('/dev/null')
)

下面是我得到的错误:

SyntaxError: ('invalid syntax', ('/usr/local/lib/python2.7/dist-packages/pymultimonaprs/multimon.py', 37, 62, "\t\t\t\t\t'-v', str(self.config['rtl'].get('debug', 'true')), '-v'],\n"))

似乎tab被扔进了-d语句中。我对python还比较陌生,正在努力解决这个问题。有什么想法吗?你知道吗


Tags: debugselfconfigjsontrue参数getdevice
2条回答
proc_src = subprocess.Popen(
   ['rtl_fm', 
    '-f', str(int(self.config['rtl']['freq'] * 1e6)),
  '-s', '22050',
   '-v', str(self.config['rtl'].get('debug', 'true')), 
  '-v', #?
   '-p', str(self.config['rtl']['ppm']), 
   '-g', str(self.config['rtl']['gain']),
   '-E', 'offset' 
   if self.config['rtl'].get('offset_tuning', False) else 'none',
   '-d', str(self.config['rtl'].get('device_index', 0)), '-'
   ],
   stdout=subprocess.PIPE, stderr=open('/dev/null'))

两个逗号:

'-v', str(self.config['rtl'].get('debug', 'true')), '-v'],,
                                                         ^^

相关问题 更多 >

    热门问题