首先,我查看了文档,发现了这个: http ://www.tutorialspoint.com/python/python_command_line_arguments.htm
然后我还发现了这个: 如何使用另一个 python 脚本文件中的参数执行 python 脚本文件
我正在使用 pycharm 2.7.3,当我尝试运行我的脚本时出现错误(该错误与 pycharm 无关)。我发现解决此错误的唯一方法是通过带有几个“参数”的 Windows PowerShell 运行脚本(这就是它的名称吗?)
下面的代码构成了我的脚本 temp.py
from sys import argv
# this what the Ide fails to run
scripts, first, second, third = argv
print "The script is called:", scripts
print "Your first variable is:", first
print "Your second variable is:", second
print "Your third variable is:", third
接下来是我在 powershell 中输入的内容 注意:上面的代码是 temp.py
python temp.py first 2nd 3rd
1)出现在“python temp.py”之后的那些文本是什么,是参数吗?
2)是否可以在IDE中使用所谓的参数运行代码(我使用的是pyCharm)
3) 如果 '2)' = True,那又如何?