我编写了Python代码来以编程方式计算IP,然后我想在外部连接程序中使用它。在子流程中使用字符串
我不知道如何将它传递给子:
import subprocess
from subprocess import call
some_ip = "192.0.2.0" # Actually the result of some computation,
# so I can't just paste it into the call below.
subprocess.call("given.exe -connect host (some_ip)::5631 -Password")
我读过我能发现类似的问题,但我真的不明白这一步,在使用的some_ip
值子进程。如果有人能向我解释这一点,将不胜感激。
我编辑了这个问题和我的答案。由于我以前的评论已经过时,我已经删除了它们。随意删除您的评论。 (他们可能会在没有上下文的情况下引起混淆。) –