我正在創建一個madlibs遊戲,需要用戶輸入並返回故事。我使用%s來存儲輸入。當我得到這個錯誤,我改變了%s到每以前的職位,但錯誤%%的遺體Python不支持的格式字符「w」
print "What is your name?"
a = raw_input()
print "Hello", a, "Lets see if you like you can do MadLibs!"
print "HEAD KNIGHT OF NI: %s \n KNIGHTS OF NI : %s \n ARTHUR : Who are you ? \n HEAD KNIGHT : We are the %s who say. %s \n RANDOM : %s \n ARTHUR : No ! Not the %s who say %s \n Head Knight: The Same! \n Bedevere: Who are they? \n Head Knight: We are the keepers of the %s words : %%s %%s and %%s \n Random: %%s \n Arthur: Those who %s them seldom live to tell the tale. \n Head Knight: The %%s who say %%s demand a sacrifice \n Arthur: %s of %s we are but %s travellers who seek the % who lives beyong these woods \n Head Knight: %s \n Knights of Ni: %s \n Arthur: Ow Agh \n Head Knight: We shall say %s again to you if you don't appease us \n Arthur: Well what is it you want? \n Head Knight: We want a %%s \n Arthur: A what? \n Knights of Ni: %%s \n Arthur and Party: OWWW, AHHH \n Arthur: Please, No More! We will find you a %%s \n Head Knight: You must return here with a %%s or else, you will never pass through these woods alive. \n Arthur: O %%s of %%s you are %%s and %%s and we will return with a %%s. \n Head Knight: One that looks %%s \n Arthur: Of Course \n Head Knight: and not too %%s \n Arthur: Yes" % (raw_input("Nonsense Word"), raw_input("Nonsense Word "), raw_input("Occupation"),raw_input("Nonsense Word"),
raw_input("Nonsense Word"), raw_input("Occupation"), raw_input("Nonsense Word"), raw_input("Adjective"), raw_input("Nonsense Word"),
錯誤是ValueError異常:不支持的格式字符「W」(0x77)的指數466
你在'who'之前有一個單獨的'%'。在那之後你也拼寫錯誤'beyong'。 – mtrw