python - 打开可执行文件的前置路径
问题描述
我正在使用 popen 在 windows vm 上运行以下命令
'tf 变更集 ...'
但是当我使用它运行它时
commandLine = 'tf changeset /noprompt /latest /loginType:OAuth /login:.,***'
process = Popen(commandLine, shell=True, stdout=PIPE, stderr=PIPE)
我在日志中看到以下内容正在执行
'C:\Azure\Agent-1/externals/tf/tf 变更集 ...'
这意味着 'C:\Azure\Agent-1/externals/tf/' 已预先添加到我的命令中。我只是期待看到
'tf 变更集 ...'
不幸的是,添加执行路径会破坏命令,有没有办法阻止 python 这样做?
解决方案
尝试将commandLine
toPopen
作为参数列表传递:
commandLine = ["tf", "changeset", "/noprompt", "/latest", "/loginType:OAuth", "/login:.,***'"]
process = Popen(commandLine, stdout=PIPE, stderr=PIPE)
推荐阅读
- python - 使用 RASA NLU 训练模型时出现 TensorFlow 错误
- javascript - 在按钮上单击显示数据库中单个用户的纬度和经度并显示在谷歌地图上
- dialogflow-es - 将 DialogFlow 提取参数映射到数据库列值
- python-3.x - 如何使用 spark_task 和 pythonOperator 向/从 Airflow X_COM 推/拉?
- php - Apache2 网络服务器上的 $_GET["_url"] 不工作
- node.js - 返回值在函数之外不起作用?
- python - 在熊猫数据框中,计算一个条件在一列中出现的次数?
- php - 移动设计与Firefox响应式设计模式不同
- java - java中的字符串操作
- angular - Angular 7:为什么我必须调用我的订阅方法两次才能生效