【发布时间】:2020-02-19 08:04:06
【问题描述】:
刚刚再次启动 Python,现在我已经陷入了以下困境......
我正在尝试将 subprocess.Popen 与一个带有空格的变量一起使用(Windows 路径)。
对变量进行打印,该变量似乎工作正常。但是在subprocess.Popen中使用变量时,变量会被第一个空格截断。
在脚本的一部分下方(变量“image_file”包含带有空格的 Windows 路径)
def start_phone(image_file):
cmd = tar_exe + " -tf "+ image_file
print (cmd)
subprocess.Popen(cmd, shell=True)
如何使用带有空格(路径)的变量的子进程?
【问题讨论】:
标签: python subprocess removing-whitespace