看下面。我不懂程序

时间:2014-11-16 04:54:40

标签: python-2.7

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

如何获得如下所示的输出

The script is called: script.py
Your first variable is: first
Your second variable is: 2nd
Your third variable is: 3rd

我从http://learnpythonthehardway.org/book/ex13.html

获得了该计划

1 个答案:

答案 0 :(得分:0)

您需要命名脚本script.py,然后从命令行运行它,如下所示:

python script.py first 2nd 3rd