exec命令为什么在运行以下代码时抛出错误?

问题描述 投票:0回答:1

这是代码:

stdin, stdout, stderr = client.exec_command(krd_spot 7/5/2019 -df UYU_GOVT_RR -debug DISCFUNC |& less)
out = stdout.read().decode('utf-8')
err = stderr.read().decode('utf-8')
print(out)

这是错误:

File "<ipython-input-15-2085d261d263>", line 1
    stdin, stdout, stderr = client.exec_command(krd_spot 7/5/2019 -df UYU_GOVT_RR -debug DISCFUNC |& less)
                                                         ^
SyntaxError: invalid syntax
python database unix syntax connection
1个回答
0
投票

命令应作为字符串传递:

stdin, stdout, stderr = client.exec_command("krd_spot 7/5/2019 -df UYU_GOVT_RR -debug DISCFUNC |& less")

© www.soinside.com 2019 - 2024. All rights reserved.