我正在尝试从.bat文件运行python脚本,但无法传递参数。请在下面找到我的代码:
.bat文件
set fileDestination = "\home\a\.."
set fileLocation = "\home\b\.."
set fileName = "myFile.xlsx"
"C:\Swdtools\Python3.6.3 X64\Python" fileTransfer.py %fileDestination% %fileLocation% %fileName%
fileTransfer.py
import sys
print(sys.argv[2])
上面的打印声明给了我
IndexError:列表索引超出范围
变量名称和等号之间的空格将成为名称的一部分,其后的空格将成为值的一部分。摆脱空白:
set fileDestination="\home\a\.."
set fileLocation="\home\b\.."
set fileName="myFile.xlsx"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句