无法将参数从“.bat”文件传递到 python 脚本
Cannot pass an argument from ".bat" file to python script
我正在尝试从我的 .bat 文件中 运行 一个 python 脚本,但我无法传递参数。请在下面找到我的代码:
.bat File
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: list index out of range
变量名和等号之间的 space 成为名称的一部分,之后的 space 成为值的一部分。去掉白色space:
set fileDestination="\home\a\.."
set fileLocation="\home\b\.."
set fileName="myFile.xlsx"
我正在尝试从我的 .bat 文件中 运行 一个 python 脚本,但我无法传递参数。请在下面找到我的代码:
.bat File
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: list index out of range
变量名和等号之间的 space 成为名称的一部分,之后的 space 成为值的一部分。去掉白色space:
set fileDestination="\home\a\.."
set fileLocation="\home\b\.."
set fileName="myFile.xlsx"