这是我如何解决这个(注:你仍然必须提供的参数在最初运行脚本)
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
first = raw_input("\nNew First Variable? ")
second = raw_input("New Second Variable? ")
third = raw_input("New Last Variable? ")
print "\n\nYour new variables are %s, %s, and %s" % (first, second, third)
这里是我得到的输出:
C:\Users\mbowyer\Documents\Python_Work>python ex13a.py 1 2 3
The script is called: ex13a.py
Your first variable is: 1
Your second variable is: 2
Your third variable is: 3
New First Variable? a
New Second Variable? b
New Last Variable? c
Your new variables are a, b, and c
C:\Users\mbowyer\Documents\Python_Work>
如果你发布了一些没有坐在办公桌上的本书的代码,那就太好了。 – jdi 2012-02-18 02:25:08
作为参考,正在讨论的练习在这里:http://learnpythonthehardway.org/book/ex13.html – checkorbored 2012-02-18 02:25:21