How to use subprocess when multiple arguments contain spaces?

后端 未结 10 2227

I\'m working on a wrapper script that will exercise a vmware executable, allowing for the automation of virtual machine startup/shutdown/register/deregister actions. I\'m t

10条回答
  •  萌比男神i
    2021-01-07 18:47

    If you have spaces in the path, the easiest way I've found to get them interpreted properly is this.

    subprocess.call('""' + path + '""')
    

    I don't know why exactly it needs double double quotes, but that is what works.

提交回复
热议问题