运行python脚本时出错-语法无效

运行python脚本时出错-语法无效,python,django,macos,python-2.7,Python,Django,Macos,Python 2.7,在运行python脚本时,我经常遇到这个错误 sudo python net-creds.py File "net-creds.py", line 75 ipr = Popen([‘/usr/local/bin/ip’, 'route'], stdout=PIPE, stderr=DN) ^ SyntaxError: invalid syntax 您使用的是“`”而不是”。因此请尝试此方法 ipr = Popen(['/usr/local/bin/

在运行python脚本时,我经常遇到这个错误

sudo python net-creds.py
  File "net-creds.py", line 75
    ipr = Popen([‘/usr/local/bin/ip’, 'route'], stdout=PIPE, stderr=DN)
                 ^
SyntaxError: invalid syntax
您使用的是“`”而不是
。因此请尝试此方法

ipr = Popen(['/usr/local/bin/ip', 'route'], stdout=PIPE, stderr=DN)

澄清一下:无效版本有“智能引号”。有效版本有普通的“哑引号”。你对输出做什么?如果要存储输出,可以使用check\u output:
c=check\u output([“ip”,“route”])