我是 python 的新手,使用 Microsoft Visual Studio
我必须运行这个(但它说需要超过 1 个值):
from sys import argv
script, first, second, third = argv
print "The script is called:", script
print "Your first variable is:", first
print "Your second variable is:", second
print "Your third variable is:", third
我知道我必须输入(例如)才能运行代码:
python ex13.py first 2nd 3rd
但是我需要在哪里写呢?
在 Visual Studio 中只有用于运行脚本的开始按钮
谢谢
原文由 axcelenator 发布,翻译遵循 CC BY-SA 4.0 许可协议
我写了一个例子。对于每个参数,您都在 for 循环中测试正确的参数。您可以将参数放在项目的属性对话框中。在调试下,例如脚本参数“-i aplha.txt”。