首页 > 解决方案 > 将参数从 Python 传递到 powershell

问题描述

我正在尝试从 Python 将参数传递给 powershell 脚本,但 powershell 只是拾取语句的第一部分并忽略空格后的所有内容这是代码:

p = subprocess.Popen(["C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe",
                      "C:/Users/fthoma15/Documents/testcase.ps1",
                      elem[2].replace('--','',1)], stdout=sys.stdout)

计算结果elem[2].replace('--','',1)为 exec storecproc 值,但是当我运行代码时,powershell 只会选择 exec 部分并忽略其余部分。有没有办法逃避变量中的空间?

标签: pythonwindowspowershellparameters

解决方案


推荐阅读