我需要在运行时将ID和密码传递给批处理文件,而不是将它们硬编码到文件中.
这是命令行的样子:
test.cmd admin P@55w0rd > test-log.txt
Run Code Online (Sandbox Code Playgroud) 我有一个简单的脚本blah.py(使用Python 2):
import sys
print sys.argv[1]
Run Code Online (Sandbox Code Playgroud)
如果我执行我的脚本:
python c:/..../blah.py argument
Run Code Online (Sandbox Code Playgroud)
它打印参数,但如果我执行脚本:
blah.py argument
Run Code Online (Sandbox Code Playgroud)
发生错误:
IndexError ...
所以参数不会传递给脚本.
PATH中的python.exe.blah.py的文件夹也在PATH中.
python.exe是执行*.py文件的默认程序.
问题是什么?