【发布时间】:2018-11-15 00:57:31
【问题描述】:
我正在通过 Codeacademy 学习 Python,但我在他们的 Madlibs 练习中遇到了问题。在我开始遇到问题后,我查看了演练,但我看不出他们的代码和模式之间有任何区别。这是我的代码:
STORY = "This morning % woke up feeling %. 'It is going to be a % day!' Outside, a bunch of %s were protesting to keep % in stores. They began to % to the rhythm of the %, which made all the %s very %. Concerned, % texted %, who flew % to % and dropped % in a puddle of frozen %. % woke up in the year %, in a world where %s ruled the world."
print "Let the Madlibs begin!"
name = raw_input("Enter a name: ")
print "Please provide three adjectives: "
adj_1 = raw_input("1: ")
adj_2 = raw_input("2: ")
adj_3 = raw_input("3: ")
verb = raw_input("Enter a verb: ")
print "Now, input two nouns:"
noun_1 = raw_input("1: ")
noun_2 = raw_input("2: ")
print "Please provide a word for:"
animal = raw_input("An animal: ")
food = raw_input("A food: ")
fruit = raw_input("A fruit: ")
superhero = raw_input("A superhero: ")
country = raw_input("A country: ")
dessert = raw_input("A dessert: ")
year = raw_input("A year: ")
print STORY % (name, adj_1, adj_2, animal, food, verb, noun_1, noun_2, adj_3, name, superhero, name, country, name, dessert, name, year, noun_2)
当我运行程序时,我收到以下错误:
Traceback(最近一次调用最后一次):文件“Madlibs.py”,第 34 行,在 print STORY % (name, adj_1, adj_2, animal, food, v erb, noun_1, noun_2, adj_3, name, superhero, name, 国家, name, 甜点, name, 年,名词_2)ValueError:不支持的格式字符'w'(0x77)在 索引 15
请帮我看看我错过了什么。谢谢!
【问题讨论】:
标签: python-2.7