简体   繁体   English

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

[英]Why does exec command thrown an error on running the following code?

This is the code:这是代码:

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)

This is the error:这是错误:

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

The command should be passed as a string:该命令应作为字符串传递:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM