一:代码
from sys import argv
script, user_name = argv
prompt = '> '
print "Hi %s, I'm the %s script." % (user_name, script)
print "I'd like to ask you a few questions."
print "Do you like me %s?" % user_name
likes = raw_input(prompt)
print "Where do you live %s?" % user_name
lives = raw_input(prompt)
print "What kind of computer do you have?"
computer = raw_input(prompt)
print """
Alright, so you said %r about liking me.
You live in %r. Not sure where that is.
And you have a %r computer. Nice.
""" % (likes, lives, computer)
二:附加练习
1:将prompt变量改成完全不同的内容再运行一遍。
2.给你的脚本再添加一个参数,并使用这个参数。
3:弄懂三个引号""”可以定义多行字符串。而%是字符串的格式化工具。