Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在VBA中传入多个参数以运行Python脚本_Python_Vba_Quotes - Fatal编程技术网

在VBA中传入多个参数以运行Python脚本

在VBA中传入多个参数以运行Python脚本,python,vba,quotes,Python,Vba,Quotes,我有一个非常简单的VBA脚本,它将运行一个Python脚本,其中指定了参数(包含空格的文件夹路径) 代码如下 Dim路径作为字符串 path=Left(pdocinfo.path,InStrRev(pdocinfo.path,“\”)例如C:\Temp\City Addresses 像字符串一样变暗 pyLocation=“C:\Temp\filePath.py” 作为字符串的Dim strReports strReports=路径和“报告” 像线一样模糊的条纹 strImages=路径和“图像

我有一个非常简单的VBA脚本,它将运行一个Python脚本,其中指定了参数(包含空格的文件夹路径)

代码如下

Dim路径作为字符串
path=Left(pdocinfo.path,InStrRev(pdocinfo.path,“\”)例如C:\Temp\City Addresses
像字符串一样变暗
pyLocation=“C:\Temp\filePath.py”
作为字符串的Dim strReports
strReports=路径和“报告”
像线一样模糊的条纹
strImages=路径和“图像”
暗淡的贝壳像长的一样
shellvar=shell(“C:\Python26\ArcGIS10.0\python.exe”&pyLocation&&path&&strImages&&strReports,vbNormalFocus)
但是,在运行Python脚本时,文件路径(
strImages
streports
path
)无法正确解析,因为它们在文件夹路径中包含空格

Python解释多个参数的正确方法是什么?这些参数是动态变量,也包含空格

编辑: 我试过下面的,下面的评论

shellvar = Shell("C:\Python27\ArcGIS10.2\python.exe " & pyLocation & " " & """" & path & """" & " " & """" & strImages & """" & " " & """" & strReports & """", vbNormalFocus)
python脚本的结果是

我想要的结果是

Argument 0: C:\Temp\filePath.py
Argument 1: "C:\Temp\City Addresses"
Argument 2: "C:\Temp\City Addresses\Images"
Argument 3: "C:\Temp\City Addresses\Reports"

用双引号括起来

shellvar = shell("C:\Python26\ArcGIS10.0\python.exe " & pyLocation & " " & """" & path & """" & " " & """" & strImages & """" & " " & """" & strReports & """", vbNormalFocus)

你可能不得不用双引号括起来“”(&strImages&“”&有四个双引号可以生成一个双引号。我已经尝试过了,但是python中使用的参数不正确。我已经更新了问题,以显示您的示例以及结果的屏幕截图。